From 9cacf0db6cffbc17af5795a7adf3684c01489d6d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 9 Jan 2017 15:15:08 +0100 Subject: [PATCH] #1068 Access mainGrid directly from RimEclipseView --- .../RimCellRangeFilterCollection.cpp | 9 +++------ .../ProjectDataModel/RimEclipseView.cpp | 4 ++-- .../ProjectDataModel/RimFaultCollection.cpp | 8 ++++---- .../ProjectDataModel/RimViewController.cpp | 18 +++++++++--------- .../ProjectDataModel/RimViewLinker.cpp | 16 +++++----------- .../UserInterface/RiuViewerCommands.cpp | 15 +++++++-------- 6 files changed, 30 insertions(+), 40 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp index 7707b14feb..418017b2ea 100644 --- a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp @@ -107,16 +107,13 @@ void RimCellRangeFilterCollection::compoundCellRangeFilter(cvf::CellRangeFilter* RigMainGrid* RimCellRangeFilterCollection::mainGrid() const { RimEclipseView* eclipseView = this->eclipseView(); - if (eclipseView && - eclipseView->eclipseCase() && - eclipseView->eclipseCase()->reservoirData() && - eclipseView->eclipseCase()->reservoirData()->mainGrid()) + if (eclipseView && eclipseView->mainGrid()) { - return eclipseView->eclipseCase()->reservoirData()->mainGrid(); + return eclipseView->mainGrid(); } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 0a70e4f213..e120dd9508 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -465,7 +465,7 @@ void RimEclipseView::createDisplayModel() */ // Well path model - RigMainGrid* mainGrid = eclipseCase()->reservoirData()->mainGrid(); + RigMainGrid* mainGrid = this->mainGrid(); m_wellPathPipeVizModel->removeAllParts(); addWellPathsToModel(m_wellPathPipeVizModel.p(), @@ -1589,7 +1589,7 @@ void RimEclipseView::setOverridePropertyFilterCollection(RimEclipsePropertyFilte void RimEclipseView::calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility) { size_t gridCount = this->eclipseCase()->reservoirData()->gridCount(); - size_t cellCount = this->eclipseCase()->reservoirData()->mainGrid()->globalCellArray().size(); + size_t cellCount = this->mainGrid()->globalCellArray().size(); totalVisibility->resize(cellCount); totalVisibility->setAll(false); diff --git a/ApplicationCode/ProjectDataModel/RimFaultCollection.cpp b/ApplicationCode/ProjectDataModel/RimFaultCollection.cpp index b2c7f1a127..a243b0d9e1 100644 --- a/ApplicationCode/ProjectDataModel/RimFaultCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimFaultCollection.cpp @@ -185,11 +185,11 @@ bool faultComparator(const cvf::ref& a, const cvf::ref& b) //-------------------------------------------------------------------------------------------------- void RimFaultCollection::syncronizeFaults() { - if (!(m_reservoirView && m_reservoirView->eclipseCase() && m_reservoirView->eclipseCase()->reservoirData() && m_reservoirView->eclipseCase()->reservoirData()->mainGrid()) ) return; + if (!(m_reservoirView && m_reservoirView->mainGrid()) ) return; cvf::ref partColors = RivColorTableArray::colorTableArray(); - const cvf::Collection constRigFaults = m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->faults(); + const cvf::Collection constRigFaults = m_reservoirView->mainGrid()->faults(); cvf::Collection rigFaults; { @@ -270,7 +270,7 @@ void RimFaultCollection::syncronizeFaults() // NNCs this->noCommonAreaNnncCollection()->noCommonAreaNncs().deleteAllChildObjects(); - RigMainGrid* mainGrid = m_reservoirView->eclipseCase()->reservoirData()->mainGrid(); + RigMainGrid* mainGrid = m_reservoirView->mainGrid(); std::vector& nncConnections = mainGrid->nncData()->connections(); for (size_t i = 0; i < nncConnections.size(); i++) { @@ -397,7 +397,7 @@ void RimFaultCollection::setShowFaultsOutsideFilters(bool enableState) //-------------------------------------------------------------------------------------------------- void RimFaultCollection::addMockData() { - if (!(m_reservoirView && m_reservoirView->eclipseCase() && m_reservoirView->eclipseCase()->reservoirData() && m_reservoirView->eclipseCase()->reservoirData()->mainGrid())) return; + if (!(m_reservoirView && m_reservoirView->mainGrid())) return; } diff --git a/ApplicationCode/ProjectDataModel/RimViewController.cpp b/ApplicationCode/ProjectDataModel/RimViewController.cpp index 560c91366f..c6e2ff7867 100644 --- a/ApplicationCode/ProjectDataModel/RimViewController.cpp +++ b/ApplicationCode/ProjectDataModel/RimViewController.cpp @@ -21,7 +21,7 @@ #include "RiaApplication.h" -#include "RigCaseData.h" +//#include "RigCaseData.h" #include "RigCaseToCaseCellMapper.h" #include "RigCaseToCaseRangeFilterMapper.h" #include "RigFemPartCollection.h" @@ -570,14 +570,14 @@ const RigCaseToCaseCellMapper* RimViewController::cellMapper() RigFemPart* masterFemPart = NULL; RigFemPart* dependFemPart = NULL; - if (masterEclipseView && masterEclipseView->eclipseCase()->reservoirData()) + if (masterEclipseView) { - masterEclGrid = masterEclipseView->eclipseCase()->reservoirData()->mainGrid(); + masterEclGrid = masterEclipseView->mainGrid(); } - if (dependEclipseView && dependEclipseView->eclipseCase()->reservoirData()) + if (dependEclipseView) { - dependEclGrid = dependEclipseView->eclipseCase()->reservoirData()->mainGrid(); + dependEclGrid = dependEclipseView->mainGrid(); } if (masterGeomechView && masterGeomechView->geoMechCase()->geoMechData() @@ -971,9 +971,9 @@ void RimViewController::updateRangeFilterOverrides(RimCellRangeFilter* changedRa if (eclipseMasterView && depGeomView) { - if (eclipseMasterView->eclipseCase()->reservoirData()) + if (eclipseMasterView->mainGrid()) { - RigMainGrid* srcEclGrid = eclipseMasterView->eclipseCase()->reservoirData()->mainGrid(); + RigMainGrid* srcEclGrid = eclipseMasterView->mainGrid(); RigFemPart* dstFemPart = depGeomView->geoMechCase()->geoMechData()->femParts()->part(0); for (size_t rfIdx = 0; rfIdx < sourceFilterCollection->rangeFilters().size(); ++rfIdx) { @@ -986,10 +986,10 @@ void RimViewController::updateRangeFilterOverrides(RimCellRangeFilter* changedRa } else if (geoMasterView && depEclView) { - if (depEclView->eclipseCase()->reservoirData()) + if (depEclView->mainGrid()) { RigFemPart* srcFemPart = geoMasterView->geoMechCase()->geoMechData()->femParts()->part(0); - RigMainGrid* dstEclGrid = depEclView->eclipseCase()->reservoirData()->mainGrid(); + RigMainGrid* dstEclGrid = depEclView->mainGrid(); for (size_t rfIdx = 0; rfIdx < sourceFilterCollection->rangeFilters().size(); ++rfIdx) { RimCellRangeFilter* srcRFilter = sourceFilterCollection->rangeFilters[rfIdx]; diff --git a/ApplicationCode/ProjectDataModel/RimViewLinker.cpp b/ApplicationCode/ProjectDataModel/RimViewLinker.cpp index 3fa9b6111a..6798a85a16 100644 --- a/ApplicationCode/ProjectDataModel/RimViewLinker.cpp +++ b/ApplicationCode/ProjectDataModel/RimViewLinker.cpp @@ -21,7 +21,7 @@ #include "RiaApplication.h" -#include "RigCaseData.h" +#include "RigMainGrid.h" #include "RimCase.h" #include "RimEclipseCellColors.h" @@ -547,12 +547,9 @@ void RimViewLinker::updateCamera(RimView* sourceView) cvf::BoundingBox sourceSceneBB = sourceView->viewer()->currentScene()->boundingBox(); RimEclipseView* eclipseView = dynamic_cast(sourceView); - if (eclipseView - && eclipseView->eclipseCase() - && eclipseView->eclipseCase()->reservoirData() - && eclipseView->eclipseCase()->reservoirData()->mainGrid()) + if (eclipseView && eclipseView->mainGrid()) { - cvf::Vec3d offset = eclipseView->eclipseCase()->reservoirData()->mainGrid()->displayModelOffset(); + cvf::Vec3d offset = eclipseView->mainGrid()->displayModelOffset(); offset.z() *= eclipseView->scaleZ(); sourceCamGlobalEye += offset; @@ -578,12 +575,9 @@ void RimViewLinker::updateCamera(RimView* sourceView) cvf::BoundingBox destSceneBB = destinationViewer->currentScene()->boundingBox(); RimEclipseView* destEclipseView = dynamic_cast(destinationView); - if (destEclipseView - && destEclipseView->eclipseCase() - && destEclipseView->eclipseCase()->reservoirData() - && destEclipseView->eclipseCase()->reservoirData()->mainGrid()) + if (destEclipseView && destEclipseView->mainGrid()) { - cvf::Vec3d destOffset = destEclipseView->eclipseCase()->reservoirData()->mainGrid()->displayModelOffset(); + cvf::Vec3d destOffset = destEclipseView->mainGrid()->displayModelOffset(); destOffset.z() *= destEclipseView->scaleZ(); cvf::Vec3d destinationCamEye = sourceCamGlobalEye - destOffset; diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index ac11722fd8..6a6f76af06 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -32,6 +32,7 @@ #include "RigFemPartCollection.h" #include "RigFemPartGrid.h" #include "RigGeoMechCaseData.h" +#include "RigMainGrid.h" #include "RimCellEdgeColors.h" #include "RimContextCommandBuilder.h" @@ -254,8 +255,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) } // Hide faults command - const RigCaseData* reservoir = eclipseView->eclipseCase()->reservoirData(); - const RigFault* fault = reservoir->mainGrid()->findFaultFromCellIndexAndCellFace(m_currentCellIndex, m_currentFaceIndex); + const RigFault* fault = eclipseView->mainGrid()->findFaultFromCellIndexAndCellFace(m_currentCellIndex, m_currentFaceIndex); if (fault) { menu.addSeparator(); @@ -400,8 +400,7 @@ void RiuViewerCommands::slotHideFault() RimEclipseView* eclipseView = dynamic_cast(m_reservoirView.p()); if(!eclipseView) return; - const RigCaseData* reservoir = eclipseView->eclipseCase()->reservoirData(); - const RigFault* fault = reservoir->mainGrid()->findFaultFromCellIndexAndCellFace(m_currentCellIndex, m_currentFaceIndex); + const RigFault* fault = eclipseView->mainGrid()->findFaultFromCellIndexAndCellFace(m_currentCellIndex, m_currentFaceIndex); if (fault) { QString faultName = fault->name(); @@ -641,7 +640,7 @@ void RiuViewerCommands::findCellAndGridIndex(const RivIntersectionSourceInfo* cr { size_t globalCellIndex = crossSectionSourceInfo->triangleToCellIndex()[firstPartTriangleIndex]; - const RigCell& cell = eclipseView->eclipseCase()->reservoirData()->mainGrid()->globalCellArray()[globalCellIndex]; + const RigCell& cell = eclipseView->mainGrid()->globalCellArray()[globalCellIndex]; *cellIndex = cell.gridLocalCellIndex(); *gridIndex = cell.hostGrid()->gridIndex(); } @@ -665,7 +664,7 @@ void RiuViewerCommands::findCellAndGridIndex(const RivIntersectionBoxSourceInfo* { size_t globalCellIndex = intersectionBoxSourceInfo->triangleToCellIndex()[firstPartTriangleIndex]; - const RigCell& cell = eclipseView->eclipseCase()->reservoirData()->mainGrid()->globalCellArray()[globalCellIndex]; + const RigCell& cell = eclipseView->mainGrid()->globalCellArray()[globalCellIndex]; *cellIndex = cell.gridLocalCellIndex(); *gridIndex = cell.hostGrid()->gridIndex(); } @@ -691,9 +690,9 @@ void RiuViewerCommands::extractIntersectionData(const cvf::HitItemCollection& hi { RimEclipseView* eclipseView = dynamic_cast(m_reservoirView.p()); - if (eclipseView && eclipseView->eclipseCase()) + if (eclipseView && eclipseView->mainGrid()) { - double characteristicCellSize = eclipseView->eclipseCase()->reservoirData()->mainGrid()->characteristicIJCellSize(); + double characteristicCellSize = eclipseView->mainGrid()->characteristicIJCellSize(); pickDepthThresholdSquared = characteristicCellSize / 100.0; pickDepthThresholdSquared = pickDepthThresholdSquared * pickDepthThresholdSquared; }