mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2913 Improve coupling between egrid and summary cases
* Convert RimGridSummaryCase to RimFileSummaryCase when closing grid.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
class RimEclipseCase;
|
||||
class RifReaderEclipseSummary;
|
||||
class RimFileSummaryCase;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
@@ -52,6 +53,7 @@ public:
|
||||
|
||||
void setIncludeRestartFiles(bool includeRestartFiles);
|
||||
|
||||
RimFileSummaryCase* createFileSummaryCaseCopy();
|
||||
private:
|
||||
QString eclipseGridFileName() const;
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -62,6 +62,7 @@ public:
|
||||
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);
|
||||
|
||||
@@ -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<RimGridSummaryCase*>(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<RimGridSummaryCase*>(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<RimFileSummaryCase*>(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 });
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RimGridSummaryCase;
|
||||
class RimSummaryCase;
|
||||
class RimEclipseResultCase;
|
||||
class RimSummaryCaseCollection;
|
||||
@@ -50,6 +51,7 @@ public:
|
||||
|
||||
RimSummaryCase* findSummaryCaseFromEclipseResultCase(RimEclipseResultCase* eclResCase) const;
|
||||
RimSummaryCase* findSummaryCaseFromFileName(const QString& fileName) const;
|
||||
void convertGridSummaryCasesToFileSummaryCases(RimGridSummaryCase* gridSummaryCase);
|
||||
|
||||
void addCases(const std::vector<RimSummaryCase*> cases);
|
||||
void addCase(RimSummaryCase* summaryCase);
|
||||
|
||||
Reference in New Issue
Block a user