From dae054cf8f53b21ba5226b840b69ec06c60cd18b Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 7 Jun 2018 16:50:50 +0200 Subject: [PATCH] #3017 Restructure UI --- .../Completions/RimFractureContainment.cpp | 101 ++++++------------ .../Completions/RimFractureContainment.h | 21 +--- .../RimFractureContainmentTools.cpp | 64 ++++++----- .../Completions/RimFractureContainmentTools.h | 11 +- 4 files changed, 75 insertions(+), 122 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureContainment.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureContainment.cpp index 3b02c1fd64..31ea078ae9 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureContainment.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureContainment.cpp @@ -23,23 +23,8 @@ #include "RimFractureTemplate.h" #include "RimProject.h" -#include "cafPdmUiSliderEditor.h" - CAF_PDM_SOURCE_INIT(RimFractureContainment, "FractureContainment"); -namespace caf -{ -template<> -void caf::AppEnum::setUp() -{ - addItem(RimFractureContainment::DISABLED, "DISABLED", "Continue Across"); - addItem(RimFractureContainment::TRUNCATE_AT_FAULT, "TRUNCATE_AT_FAULT", "Truncate At Faults"); - addItem(RimFractureContainment::CONTINUE_IN_CONTAINMENT_ZONE, "CONTINUE_IN_CONTAINMENT_ZONE", "Continue in Containment Zone"); - - setDefault(RimFractureContainment::DISABLED); -} -} // namespace caf - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -47,20 +32,13 @@ RimFractureContainment::RimFractureContainment() { CAF_PDM_InitObject("Fracture Containment", "", "", ""); - CAF_PDM_InitField( - &m_isUsingFractureContainment_OBSOLETE, "IsUsingFractureContainment", false, "Fracture Containment", "", "", ""); - m_isUsingFractureContainment_OBSOLETE.xmlCapability()->setIOWritable(false); - m_isUsingFractureContainment_OBSOLETE.uiCapability()->setUiHidden(true); + CAF_PDM_InitField(&m_useContainment, "IsUsingFractureContainment", false, "Use Containment", "", "", ""); + CAF_PDM_InitField(&m_topKLayer, "TopKLayer", 0, " Top Layer", "", "", ""); + CAF_PDM_InitField(&m_baseKLayer, "BaseKLayer", 0, " Base Layer", "", "", ""); - CAF_PDM_InitField(&m_topKLayer, "TopKLayer", 0, "Top Layer", "", "", ""); - // m_topKLayer.uiCapability()->setUiEditorTypeName(caf::PdmUiSliderEditor::uiEditorTypeName()); - CAF_PDM_InitField(&m_baseKLayer, "BaseKLayer", 0, "Base Layer", "", "", ""); - // m_topKLayer.uiCapability()->setUiEditorTypeName(caf::PdmUiSliderEditor::uiEditorTypeName()); - - CAF_PDM_InitFieldNoDefault(&m_faultTruncation, "FaultTruncationType", "Fault Truncation", "", "", ""); - - CAF_PDM_InitField(&m_useFaultThrow, "UseFaultThrow", false, "Use Fault Throw", "", "", ""); - CAF_PDM_InitField(&m_faultThrowValue, "FaultThrowValue", 0.0f, " Fault Throw", "", "", ""); + CAF_PDM_InitField(&m_truncateAtFaults, "TruncateAtFaults", false, "Truncate At Faults", "", "", ""); + CAF_PDM_InitField(&m_useFaultThrow, "UseFaultThrow", false, " Use Fault Throw", "", "", ""); + CAF_PDM_InitField(&m_maximumFaultThrow, "FaultThrowValue", 0.0f, " Maximum Fault Throw", "", "", ""); } //-------------------------------------------------------------------------------------------------- @@ -71,32 +49,11 @@ RimFractureContainment::~RimFractureContainment() {} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RimFractureContainment::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly) +double RimFractureContainment::maximumFaultThrow() const { - // TODO: Remove this - return caf::PdmObject::calculateValueOptions(fieldNeedingOptions, useOptionsOnly); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimFractureContainment::initAfterRead() -{ - if (m_isUsingFractureContainment_OBSOLETE()) + if (m_truncateAtFaults() && m_useFaultThrow()) { - m_faultTruncation = CONTINUE_IN_CONTAINMENT_ZONE; - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -double RimFractureContainment::faultThrow() const -{ - if ((m_faultTruncation() == CONTINUE_IN_CONTAINMENT_ZONE || m_faultTruncation() == TRUNCATE_AT_FAULT) && m_useFaultThrow()) - { - return m_faultThrowValue; + return m_maximumFaultThrow; } return -1.0; @@ -107,7 +64,7 @@ double RimFractureContainment::faultThrow() const //-------------------------------------------------------------------------------------------------- bool RimFractureContainment::isEnabled() const { - return m_faultTruncation() != DISABLED; + return (m_useContainment() || m_truncateAtFaults()); } //-------------------------------------------------------------------------------------------------- @@ -120,7 +77,7 @@ bool RimFractureContainment::isEclipseCellWithinContainment(const RigMainGrid* { if (!isEnabled()) return true; - if (m_faultTruncation() == CONTINUE_IN_CONTAINMENT_ZONE || m_faultTruncation() == TRUNCATE_AT_FAULT) + if (m_useContainment()) { CVF_ASSERT(mainGrid); @@ -140,7 +97,7 @@ bool RimFractureContainment::isEclipseCellWithinContainment(const RigMainGrid* } } - if (m_faultTruncation() == TRUNCATE_AT_FAULT) + if (m_truncateAtFaults()) { if (containmentCells.count(globalCellIndex) > 0) { @@ -176,21 +133,27 @@ void RimFractureContainment::setBaseKLayer(int baseKLayer) //-------------------------------------------------------------------------------------------------- void RimFractureContainment::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { - uiOrdering.add(&m_faultTruncation); + uiOrdering.add(&m_useContainment); + uiOrdering.add(&m_topKLayer); + uiOrdering.add(&m_baseKLayer); - if (m_faultTruncation() == CONTINUE_IN_CONTAINMENT_ZONE || m_faultTruncation() == TRUNCATE_AT_FAULT) + m_topKLayer.uiCapability()->setUiReadOnly(!m_useContainment()); + m_baseKLayer.uiCapability()->setUiReadOnly(!m_useContainment()); + + uiOrdering.add(&m_truncateAtFaults); + uiOrdering.add(&m_useFaultThrow); + uiOrdering.add(&m_maximumFaultThrow); + + m_useFaultThrow.uiCapability()->setUiReadOnly(!m_truncateAtFaults()); + + if (m_truncateAtFaults() && m_useFaultThrow()) { - uiOrdering.add(&m_topKLayer); - uiOrdering.add(&m_baseKLayer); - - uiOrdering.add(&m_useFaultThrow); - if (m_useFaultThrow()) - { - uiOrdering.add(&m_faultThrowValue); - } + m_maximumFaultThrow.uiCapability()->setUiReadOnly(false); + } + else + { + m_maximumFaultThrow.uiCapability()->setUiReadOnly(true); } - - uiOrdering.skipRemainingFields(); } //-------------------------------------------------------------------------------------------------- @@ -200,8 +163,6 @@ void RimFractureContainment::fieldChangedByUi(const caf::PdmFieldHandle* changed const QVariant& oldValue, const QVariant& newValue) { - if (changedField == &m_faultTruncation || changedField == &m_topKLayer || changedField == &m_baseKLayer || - changedField == &m_useFaultThrow || changedField == &m_faultThrowValue) { RimProject* proj; this->firstAncestorOrThisOfType(proj); @@ -211,7 +172,7 @@ void RimFractureContainment::fieldChangedByUi(const caf::PdmFieldHandle* changed } } - if (changedField == &m_useFaultThrow || changedField == &m_faultTruncation) + if (changedField == &m_useFaultThrow || changedField == &m_useContainment || changedField == &m_truncateAtFaults) { RimFractureTemplate* fractureTemplate = nullptr; this->firstAncestorOrThisOfType(fractureTemplate); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureContainment.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureContainment.h index 44d36fa36c..cf232adb38 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureContainment.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureContainment.h @@ -19,7 +19,6 @@ #include "cafPdmObject.h" #include "cafPdmField.h" -#include "cafAppEnum.h" class RigMainGrid; @@ -34,36 +33,24 @@ public: RimFractureContainment(); ~RimFractureContainment(); - enum FaultTruncType - { - DISABLED, - TRUNCATE_AT_FAULT, - CONTINUE_IN_CONTAINMENT_ZONE - }; - bool isEnabled() const; bool isEclipseCellWithinContainment(const RigMainGrid* mainGrid, size_t anchorEclipseCell, size_t globalCellIndex, const std::set& containmentCells) const; void setTopKLayer(int topKLayer); void setBaseKLayer(int baseKLayer); - double faultThrow() const; // Negative value means do not test for fault throw + double maximumFaultThrow() const; // Negative value means do not test for fault throw private: virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) 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 void initAfterRead() override; private: - friend caf::AppEnum< FaultTruncType >; - caf::PdmField< caf::AppEnum< FaultTruncType > > m_faultTruncation; - + caf::PdmField m_useContainment; caf::PdmField m_topKLayer; caf::PdmField m_baseKLayer; + caf::PdmField m_truncateAtFaults; caf::PdmField m_useFaultThrow; - caf::PdmField m_faultThrowValue; - - caf::PdmField m_isUsingFractureContainment_OBSOLETE; + caf::PdmField m_maximumFaultThrow; }; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureContainmentTools.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureContainmentTools.cpp index 60a53ef383..08932f15f9 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureContainmentTools.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureContainmentTools.cpp @@ -18,7 +18,6 @@ #include "RimFractureContainmentTools.h" -#include "RigActiveCellInfo.h" #include "RigEclipseCaseData.h" #include "RigFault.h" #include "RigHexIntersectionTools.h" @@ -43,7 +42,7 @@ void RimFractureContainmentTools::appendNeighborCellForFace(const std::set& connectedCells, - double faultThrow) + double maximumFaultThrow) { // TODO: Remove when we know if LGR can have faults @@ -53,7 +52,7 @@ void RimFractureContainmentTools::appendNeighborCellForFace(const std::setcellIJKNeighbor(anchorI, anchorJ, anchorK, face, &candidate)) { - appendNeighborCells(allFracturedCells, mainGrid, candidate, connectedCells, faultThrow); + appendNeighborCells(allFracturedCells, mainGrid, candidate, connectedCells, maximumFaultThrow); } } @@ -65,12 +64,12 @@ void RimFractureContainmentTools::checkFaultAndAppendNeighborCell(const std::set size_t globalReservoirCellIndex, cvf::StructGridInterface::FaceType face, std::set& connectedCells, - double faultThrow) + double maximumFaultThrow) { const RigFault* fault = mainGrid->findFaultFromCellIndexAndCellFace(globalReservoirCellIndex, face); if (fault) { - if (faultThrow < 0.0) + if (maximumFaultThrow < 0.0) { return; } @@ -87,7 +86,7 @@ void RimFractureContainmentTools::checkFaultAndAppendNeighborCell(const std::set size_t i, j, k; hostGrid->ijkFromCellIndex(gridLocalCellIndex, &i, &j, &k); - + size_t neighborGridLocalCellIndex; bool foundCell = hostGrid->cellIJKNeighbor(i, j, k, face, &neighborGridLocalCellIndex); @@ -95,18 +94,19 @@ void RimFractureContainmentTools::checkFaultAndAppendNeighborCell(const std::set size_t neighborGlobalReservoirCellIndex = hostGrid->reservoirCellIndex(neighborGridLocalCellIndex); - const RigCell& currentCell = mainGrid->globalCellArray()[globalReservoirCellIndex]; + const RigCell& currentCell = mainGrid->globalCellArray()[globalReservoirCellIndex]; const RigCell& neightborCell = mainGrid->globalCellArray()[neighborGlobalReservoirCellIndex]; - auto diffBetweenFaceCenters = currentCell.faceCenter(face) - neightborCell.faceCenter(cvf::StructGridInterface::oppositeFace(face)); - if (diffBetweenFaceCenters.length() < faultThrow) + auto diffBetweenFaceCenters = + currentCell.faceCenter(face) - neightborCell.faceCenter(cvf::StructGridInterface::oppositeFace(face)); + if (diffBetweenFaceCenters.length() > maximumFaultThrow) { return; } } } - appendNeighborCellForFace(allFracturedCells, mainGrid, globalReservoirCellIndex, face, connectedCells, faultThrow); + appendNeighborCellForFace(allFracturedCells, mainGrid, globalReservoirCellIndex, face, connectedCells, maximumFaultThrow); } //-------------------------------------------------------------------------------------------------- @@ -116,7 +116,7 @@ void RimFractureContainmentTools::appendNeighborCells(const std::set& al const RigMainGrid* mainGrid, size_t currentCell, std::set& connectedCells, - double faultThrow) + double maximumFaultThrow) { if (std::find(connectedCells.begin(), connectedCells.end(), currentCell) != connectedCells.end()) { @@ -133,14 +133,20 @@ void RimFractureContainmentTools::appendNeighborCells(const std::set& al connectedCells.insert(currentCell); // Check faults in IJ directions - checkFaultAndAppendNeighborCell(allFracturedCells, mainGrid, currentCell, cvf::StructGridInterface::NEG_I, connectedCells, faultThrow); - checkFaultAndAppendNeighborCell(allFracturedCells, mainGrid, currentCell, cvf::StructGridInterface::POS_I, connectedCells, faultThrow); - checkFaultAndAppendNeighborCell(allFracturedCells, mainGrid, currentCell, cvf::StructGridInterface::NEG_J, connectedCells, faultThrow); - checkFaultAndAppendNeighborCell(allFracturedCells, mainGrid, currentCell, cvf::StructGridInterface::POS_J, connectedCells, faultThrow); + checkFaultAndAppendNeighborCell( + allFracturedCells, mainGrid, currentCell, cvf::StructGridInterface::NEG_I, connectedCells, maximumFaultThrow); + checkFaultAndAppendNeighborCell( + allFracturedCells, mainGrid, currentCell, cvf::StructGridInterface::POS_I, connectedCells, maximumFaultThrow); + checkFaultAndAppendNeighborCell( + allFracturedCells, mainGrid, currentCell, cvf::StructGridInterface::NEG_J, connectedCells, maximumFaultThrow); + checkFaultAndAppendNeighborCell( + allFracturedCells, mainGrid, currentCell, cvf::StructGridInterface::POS_J, connectedCells, maximumFaultThrow); // Append cells without fault check in K direction - appendNeighborCellForFace(allFracturedCells, mainGrid, currentCell, cvf::StructGridInterface::NEG_K, connectedCells, faultThrow); - appendNeighborCellForFace(allFracturedCells, mainGrid, currentCell, cvf::StructGridInterface::POS_K, connectedCells, faultThrow); + appendNeighborCellForFace( + allFracturedCells, mainGrid, currentCell, cvf::StructGridInterface::NEG_K, connectedCells, maximumFaultThrow); + appendNeighborCellForFace( + allFracturedCells, mainGrid, currentCell, cvf::StructGridInterface::POS_K, connectedCells, maximumFaultThrow); } //-------------------------------------------------------------------------------------------------- @@ -156,25 +162,26 @@ std::set RimFractureContainmentTools::fracturedCellsTruncatedByFaults(co auto eclipseCaseData = eclipseCase->eclipseCaseData(); if (eclipseCaseData) { - auto mainGrid = eclipseCaseData->mainGrid(); - auto activeCellInfo = eclipseCaseData->activeCellInfo(RiaDefines::MATRIX_MODEL); + auto mainGrid = eclipseCaseData->mainGrid(); - if (mainGrid && activeCellInfo) + if (mainGrid) { - std::set cellsIntersectingFracturePlane = - getCellsIntersectingFracturePlane(mainGrid, activeCellInfo, fracture); + std::set cellsIntersectingFracturePlane = getCellsIntersectingFracturePlane(mainGrid, fracture); size_t anchorCellGlobalIndex = fracture->findAnchorEclipseCell(mainGrid); // Negative faultThrow disables test on faultThrow - double faultThrow = -1.0; + double maximumFaultThrow = -1.0; if (fracture && fracture->fractureTemplate()) { - faultThrow = fracture->fractureTemplate()->fractureContainment()->faultThrow(); + maximumFaultThrow = fracture->fractureTemplate()->fractureContainment()->maximumFaultThrow(); } - appendNeighborCells( - cellsIntersectingFracturePlane, mainGrid, anchorCellGlobalIndex, fracturedCellsContainedByFaults, faultThrow); + appendNeighborCells(cellsIntersectingFracturePlane, + mainGrid, + anchorCellGlobalIndex, + fracturedCellsContainedByFaults, + maximumFaultThrow); } /* @@ -194,9 +201,8 @@ std::set RimFractureContainmentTools::fracturedCellsTruncatedByFaults(co //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::set RimFractureContainmentTools::getCellsIntersectingFracturePlane(const RigMainGrid* mainGrid, - const RigActiveCellInfo* activeCellInfo, - RimFracture* fracture) +std::set RimFractureContainmentTools::getCellsIntersectingFracturePlane(const RigMainGrid* mainGrid, + RimFracture* fracture) { std::set eclipseCellIndices; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureContainmentTools.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureContainmentTools.h index b8b81e3522..b7c509d2ba 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureContainmentTools.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureContainmentTools.h @@ -24,7 +24,6 @@ #include class RigMainGrid; -class RigActiveCellInfo; class RimFracture; class RimEclipseCase; @@ -35,26 +34,26 @@ public: private: // TODO: Try to change RimStimPlanFractureTemplate::fractureTriangleGeometry to be able to use const RimFracture - static std::set - getCellsIntersectingFracturePlane(const RigMainGrid* mainGrid, const RigActiveCellInfo* activeCellInfo, RimFracture* fracture); + static std::set getCellsIntersectingFracturePlane(const RigMainGrid* mainGrid, + RimFracture* fracture); static void appendNeighborCellForFace(const std::set& allFracturedCells, const RigMainGrid* mainGrid, size_t currentCell, cvf::StructGridInterface::FaceType face, std::set& connectedCells, - double faultThrow); + double maximumFaultThrow); static void checkFaultAndAppendNeighborCell(const std::set& allFracturedCells, const RigMainGrid* mainGrid, size_t currentCell, cvf::StructGridInterface::FaceType face, std::set& connectedCells, - double faultThrow); + double maximumFaultThrow); static void appendNeighborCells(const std::set& allFracturedCells, const RigMainGrid* mainGrid, size_t currentCell, std::set& connectedCells, - double faultThrow); + double maximumFaultThrow); };