#1670 Move grid functions from RimCellRangeFilterCollection to RigReservoirGridTools

This commit is contained in:
Magne Sjaastad
2017-06-28 13:46:19 +02:00
parent 7cc95c3fa8
commit 468d5134cb
7 changed files with 243 additions and 167 deletions

View File

@@ -22,16 +22,17 @@
#include "RimCellRangeFilter.h"
#include "RigActiveCellInfo.h"
#include "RigGridBase.h"
#include "RigMainGrid.h"
#include "RigReservoirGridTools.h"
#include "RimEclipseCase.h"
#include "RimCellRangeFilterCollection.h"
#include "RimEclipseCase.h"
#include "RimEclipseView.h"
#include "RimViewController.h"
#include "cafPdmUiSliderEditor.h"
#include "cvfAssert.h"
#include "cvfStructGrid.h"
CAF_PDM_SOURCE_INIT(RimCellRangeFilter, "CellRangeFilter");
@@ -125,8 +126,16 @@ void RimCellRangeFilter::setDefaultValues()
const cvf::StructGridInterface* grid = selectedGrid();
RigActiveCellInfo* actCellInfo = parentContainer()->activeCellInfo();
if (grid == parentContainer()->gridByIndex(0) && actCellInfo)
RimView* rimView = nullptr;
this->firstAncestorOrThisOfTypeAsserted(rimView);
RigActiveCellInfo* actCellInfo = RigReservoirGridTools::activeCellInfo(rimView);
RimCase* rimCase = nullptr;
this->firstAncestorOrThisOfTypeAsserted(rimCase);
const cvf::StructGridInterface* mainGrid = RigReservoirGridTools::mainGrid(rimCase);
if (grid == mainGrid && actCellInfo)
{
cvf::Vec3st min, max;
actCellInfo->IJKBoundingBox(min, max);
@@ -195,8 +204,15 @@ void RimCellRangeFilter::defineEditorAttribute(const caf::PdmFieldHandle* field,
myAttr->m_maximum = static_cast<int>(grid->cellCountK());
}
RigActiveCellInfo* actCellInfo = parentContainer()->activeCellInfo();
if (grid == parentContainer()->gridByIndex(0) && actCellInfo)
RimCase* rimCase = nullptr;
this->firstAncestorOrThisOfTypeAsserted(rimCase);
const cvf::StructGridInterface* mainGrid = RigReservoirGridTools::mainGrid(rimCase);
RimView* rimView = nullptr;
this->firstAncestorOrThisOfTypeAsserted(rimView);
RigActiveCellInfo* actCellInfo = RigReservoirGridTools::activeCellInfo(rimView);
if (grid == mainGrid && actCellInfo)
{
cvf::Vec3st min, max;
actCellInfo->IJKBoundingBox(min, max);
@@ -264,12 +280,15 @@ QList<caf::PdmOptionItemInfo> RimCellRangeFilter::calculateValueOptions(const ca
if (useOptionsOnly) (*useOptionsOnly) = true;
if (&gridIndex == fieldNeedingOptions)
{
for (int gIdx = 0; gIdx < parentContainer()->gridCount(); ++gIdx)
{
RimCase* rimCase = nullptr;
this->firstAncestorOrThisOfTypeAsserted(rimCase);
for (int gIdx = 0; gIdx < RigReservoirGridTools::gridCount(rimCase); ++gIdx)
{
QString gridName;
gridName += parentContainer()->gridName(gIdx);
gridName += RigReservoirGridTools::gridName(rimCase, gIdx);
if (gIdx == 0)
{
if (gridName.isEmpty())
@@ -307,15 +326,15 @@ bool RimCellRangeFilter::isRangeFilterControlled() const
//--------------------------------------------------------------------------------------------------
const cvf::StructGridInterface* RimCellRangeFilter::selectedGrid()
{
if (gridIndex() >= parentContainer()->gridCount())
RimCase* rimCase = nullptr;
this->firstAncestorOrThisOfTypeAsserted(rimCase);
int clampedIndex = gridIndex();
if (clampedIndex >= RigReservoirGridTools::gridCount(rimCase))
{
gridIndex = 0;
clampedIndex = 0;
}
const cvf::StructGridInterface* grid = parentContainer()->gridByIndex(gridIndex());
CVF_ASSERT(grid);
return grid;
return RigReservoirGridTools::gridByIndex(rimCase, clampedIndex);
}

View File

@@ -20,22 +20,15 @@
#include "RimCellRangeFilterCollection.h"
#include "RigFemPart.h"
#include "RigFemPartCollection.h"
#include "RigFemPartGrid.h"
#include "RigGeoMechCaseData.h"
#include "RigMainGrid.h"
#include "RimCellRangeFilter.h"
#include "RimEclipseCase.h"
#include "RimEclipseView.h"
#include "RimGeoMechCase.h"
#include "RimGeoMechView.h"
#include "RimView.h"
#include "RimViewController.h"
#include "RimViewLinker.h"
#include "cafPdmUiEditorHandle.h"
#include "cvfStructGridGeometryGenerator.h"
CAF_PDM_SOURCE_INIT(RimCellRangeFilterCollection, "CellRangeFilterCollection");
@@ -101,35 +94,6 @@ void RimCellRangeFilterCollection::compoundCellRangeFilter(cvf::CellRangeFilter*
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigMainGrid* RimCellRangeFilterCollection::mainGrid() const
{
RimEclipseView* eclipseView = this->eclipseView();
if (eclipseView && eclipseView->mainGrid())
{
return eclipseView->mainGrid();
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigActiveCellInfo* RimCellRangeFilterCollection::activeCellInfo() const
{
RimEclipseView* eclipseView = this->eclipseView();
if (eclipseView)
{
return eclipseView->currentActiveCellInfo();
}
return NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -168,14 +132,6 @@ void RimCellRangeFilterCollection::updateDisplayModeNotifyManagedViews(RimCellRa
view->scheduleCreateDisplayModelAndRedraw();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseView* RimCellRangeFilterCollection::eclipseView() const
{
return dynamic_cast<RimEclipseView*>(baseView());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -214,89 +170,6 @@ bool RimCellRangeFilterCollection::hasActiveIncludeFilters() const
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const cvf::StructGridInterface* RimCellRangeFilterCollection::gridByIndex(int gridIndex) const
{
RigMainGrid* mnGrid = mainGrid();
RigFemPartCollection* femPartColl = this->femPartColl();
if (mnGrid)
{
RigGridBase* grid = mnGrid->gridByIndex(gridIndex);
CVF_ASSERT(grid);
return grid;
}
else if (femPartColl)
{
if (gridIndex < femPartColl->partCount())
return femPartColl->part(gridIndex)->structGrid();
else
return NULL;
}
return NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimCellRangeFilterCollection::gridCount() const
{
RigMainGrid* mnGrid = mainGrid();
RigFemPartCollection* femPartColl = this->femPartColl();
if (mnGrid)
{
return (int)mnGrid->gridCount();
}
else if (femPartColl)
{
return femPartColl->partCount();
}
return 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimCellRangeFilterCollection::gridName(int gridIndex) const
{
RigMainGrid* mnGrid = mainGrid();
RigFemPartCollection* femPartColl = this->femPartColl();
if (mnGrid)
{
return mnGrid->gridByIndex(gridIndex)->gridName().c_str();
}
else if (femPartColl)
{
return QString::number(gridIndex);
}
return "";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemPartCollection* RimCellRangeFilterCollection::femPartColl() const
{
RimGeoMechView* geoView = dynamic_cast<RimGeoMechView*>(baseView());
if (geoView &&
geoView->geoMechCase() &&
geoView->geoMechCase()->geoMechData() )
{
return geoView->geoMechCase()->geoMechData()->femParts();
}
return NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -22,17 +22,11 @@
#include "cafPdmChildArrayField.h"
#include "cafPdmField.h"
class RigActiveCellInfo;
class RigFemPartCollection;
class RigGridBase;
class RimView;
class RimCellRangeFilter;
class RimEclipseView;
class RigMainGrid;
namespace cvf {
class CellRangeFilter;
class StructGridInterface;
};
//==================================================================================================
@@ -55,12 +49,6 @@ public:
bool hasActiveFilters() const;
bool hasActiveIncludeFilters() const;
const cvf::StructGridInterface* gridByIndex(int gridIndex) const;
int gridCount() const;
QString gridName(int gridIndex) const;
RigActiveCellInfo* activeCellInfo() const;
void updateDisplayModeNotifyManagedViews(RimCellRangeFilter* changedRangeFilter);
void updateIconState();
@@ -71,9 +59,4 @@ protected:
private:
RimView* baseView() const;
private:
RimEclipseView* eclipseView() const;
RigMainGrid* mainGrid() const;
RigFemPartCollection* femPartColl() const;
};

View File

@@ -22,9 +22,9 @@
#include "RigActiveCellInfo.h"
#include "RigCaseCellResultsData.h"
#include "RigReservoirGridTools.h"
#include "RimCase.h"
#include "RimCellRangeFilterCollection.h"
#include "RimEclipseView.h"
#include "RimProject.h"
#include "RimReservoirCellResultsStorage.h"
@@ -179,8 +179,12 @@ void RimMultiSnapshotDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha
if (view())
{
mainGrid = view()->rangeFilterCollection()->gridByIndex(0);
actCellInfo = view()->rangeFilterCollection()->activeCellInfo();
actCellInfo = RigReservoirGridTools::activeCellInfo(view());
RimCase* rimCase = nullptr;
view()->firstAncestorOrThisOfTypeAsserted(rimCase);
mainGrid = RigReservoirGridTools::mainGrid(rimCase);
}
if (mainGrid && actCellInfo)

View File

@@ -11,6 +11,7 @@ set (SOURCE_GROUP_HEADER_FILES
${CEE_CURRENT_LIST_DIR}RigCaseToCaseRangeFilterMapper.h
${CEE_CURRENT_LIST_DIR}RigSimulationWellCenterLineCalculator.h
${CEE_CURRENT_LIST_DIR}RigWellLogFile.h
${CEE_CURRENT_LIST_DIR}RigReservoirGridTools.h
)
set (SOURCE_GROUP_SOURCE_FILES
@@ -20,6 +21,7 @@ set (SOURCE_GROUP_SOURCE_FILES
${CEE_CURRENT_LIST_DIR}RigCaseToCaseRangeFilterMapper.cpp
${CEE_CURRENT_LIST_DIR}RigSimulationWellCenterLineCalculator.cpp
${CEE_CURRENT_LIST_DIR}RigWellLogFile.cpp
${CEE_CURRENT_LIST_DIR}RigReservoirGridTools.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@@ -0,0 +1,143 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RigReservoirGridTools.h"
#include "RigActiveCellInfo.h"
#include "RigEclipseCaseData.h"
#include "RigFemPartCollection.h"
#include "RigFemPartGrid.h"
#include "RigGeoMechCaseData.h"
#include "RigMainGrid.h"
#include "RimEclipseCase.h"
#include "RimGeoMechCase.h"
#include "RimEclipseView.h"
#include <QString>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RigReservoirGridTools::gridCount(RimCase* rimCase)
{
RigMainGrid* eclipseMainGrid = RigReservoirGridTools::eclipseMainGrid(rimCase);
RigFemPartCollection* geoMechPartCollection = RigReservoirGridTools::geoMechPartCollection(rimCase);
if (eclipseMainGrid)
{
return eclipseMainGrid->gridCount();
}
else if (geoMechPartCollection)
{
return geoMechPartCollection->partCount();
}
return 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const cvf::StructGridInterface* RigReservoirGridTools::mainGrid(RimCase* rimCase)
{
return gridByIndex(rimCase, 0);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const cvf::StructGridInterface* RigReservoirGridTools::gridByIndex(RimCase* rimCase, int gridIndex)
{
RigMainGrid* eclipseMainGrid = RigReservoirGridTools::eclipseMainGrid(rimCase);
RigFemPartCollection* geoMechPartCollection = RigReservoirGridTools::geoMechPartCollection(rimCase);
if (eclipseMainGrid)
{
return eclipseMainGrid->gridByIndex(gridIndex);
}
else if (geoMechPartCollection)
{
return geoMechPartCollection->part(gridIndex)->structGrid();
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RigReservoirGridTools::gridName(RimCase* rimCase, int gridIndex)
{
RigMainGrid* eclipseMainGrid = RigReservoirGridTools::eclipseMainGrid(rimCase);
RigFemPartCollection* geoMechPartCollection = RigReservoirGridTools::geoMechPartCollection(rimCase);
if (eclipseMainGrid)
{
return eclipseMainGrid->gridByIndex(gridIndex)->gridName().c_str();
}
else if (geoMechPartCollection)
{
return QString::number(gridIndex);
}
return "";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigActiveCellInfo* RigReservoirGridTools::activeCellInfo(RimView* rimView)
{
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(rimView);
if (eclipseView)
{
return eclipseView->currentActiveCellInfo();
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigMainGrid* RigReservoirGridTools::eclipseMainGrid(RimCase* rimCase)
{
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(rimCase);
if (eclipseCase && eclipseCase->eclipseCaseData())
{
return eclipseCase->eclipseCaseData()->mainGrid();
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemPartCollection* RigReservoirGridTools::geoMechPartCollection(RimCase* rimCase)
{
RimGeoMechCase* geoMechCase = dynamic_cast<RimGeoMechCase*>(rimCase);
if (geoMechCase && geoMechCase->geoMechData())
{
return geoMechCase->geoMechData()->femParts();
}
return nullptr;
}

View File

@@ -0,0 +1,52 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
class RigActiveCellInfo;
class RigFemPartCollection;
class RigMainGrid;
class RimCase;
class RimView;
namespace cvf
{
class StructGridInterface;
}
class QString;
//==================================================================================================
///
///
//==================================================================================================
class RigReservoirGridTools
{
public:
static int gridCount(RimCase* rimCase);
static const cvf::StructGridInterface* mainGrid(RimCase* rimCase);
static const cvf::StructGridInterface* gridByIndex(RimCase* rimCase, int gridIndex);
static QString gridName(RimCase* rimCase, int gridIndex);
static RigActiveCellInfo* activeCellInfo(RimView* rimView);
private:
static RigMainGrid* eclipseMainGrid(RimCase* rimCase);
static RigFemPartCollection* geoMechPartCollection(RimCase* rimCase);
};