mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1018 Snapshot - Added support for multiple result variables
This commit is contained in:
parent
ebf5b01234
commit
4515579d52
@ -116,59 +116,49 @@ void RicExportMultipleSnapshotsFeature::exportMultipleSnapshots(const QString& f
|
||||
|
||||
int initialFramIndex = rimView->viewer()->currentFrameIndex();
|
||||
|
||||
exportViewVariationsToFolder(rimView, msd, folder);
|
||||
exportResultVariations(rimView, msd, folder);
|
||||
|
||||
for (RimCase* rimCase : msd->additionalCases())
|
||||
{
|
||||
RimView* copyOfView = dynamic_cast<RimView*>(rimView->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
|
||||
|
||||
RimEclipseCase* eclCase = dynamic_cast<RimEclipseCase*>(rimCase);
|
||||
if (eclCase)
|
||||
{
|
||||
RimEclipseView* eclView = dynamic_cast<RimEclipseView*>(copyOfView);
|
||||
CVF_ASSERT(eclView);
|
||||
RimEclipseView* copyOfEclipseView = eclCase->createCopyAndAddView(dynamic_cast<RimEclipseView*>(rimView));
|
||||
CVF_ASSERT(copyOfEclipseView);
|
||||
|
||||
eclCase->reservoirViews().push_back(eclView);
|
||||
copyOfEclipseView->loadDataAndUpdate();
|
||||
|
||||
eclView->setEclipseCase(eclCase);
|
||||
exportResultVariations(copyOfEclipseView, msd, folder);
|
||||
|
||||
// Resolve references after reservoir view has been inserted into Rim structures
|
||||
// Intersections referencing a well path/ simulation well requires this
|
||||
// TODO: initAfterReadRecursively can probably be removed
|
||||
eclView->initAfterReadRecursively();
|
||||
eclView->resolveReferencesRecursively();
|
||||
|
||||
eclView->loadDataAndUpdate();
|
||||
|
||||
exportViewVariationsToFolder(eclView, msd, folder);
|
||||
|
||||
eclCase->reservoirViews().removeChildObject(eclView);
|
||||
eclCase->reservoirViews().removeChildObject(copyOfEclipseView);
|
||||
|
||||
delete copyOfEclipseView;
|
||||
}
|
||||
|
||||
RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>(rimCase);
|
||||
if (geomCase)
|
||||
{
|
||||
RimGeoMechView* geoMechView = dynamic_cast<RimGeoMechView*>(copyOfView);
|
||||
CVF_ASSERT(geoMechView);
|
||||
RimGeoMechView* copyOfGeoMechView = dynamic_cast<RimGeoMechView*>(rimView->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
|
||||
CVF_ASSERT(copyOfGeoMechView);
|
||||
|
||||
geomCase->geoMechViews().push_back(geoMechView);
|
||||
geomCase->geoMechViews().push_back(copyOfGeoMechView);
|
||||
|
||||
geoMechView->setGeoMechCase(geomCase);
|
||||
copyOfGeoMechView->setGeoMechCase(geomCase);
|
||||
|
||||
// Resolve references after reservoir view has been inserted into Rim structures
|
||||
// Intersections referencing a well path/ simulation well requires this
|
||||
// TODO: initAfterReadRecursively can probably be removed
|
||||
geoMechView->initAfterReadRecursively();
|
||||
geoMechView->resolveReferencesRecursively();
|
||||
copyOfGeoMechView->initAfterReadRecursively();
|
||||
copyOfGeoMechView->resolveReferencesRecursively();
|
||||
|
||||
geoMechView->loadDataAndUpdate();
|
||||
copyOfGeoMechView->loadDataAndUpdate();
|
||||
|
||||
exportViewVariationsToFolder(geoMechView, msd, folder);
|
||||
exportResultVariations(copyOfGeoMechView, msd, folder);
|
||||
|
||||
geomCase->geoMechViews().removeChildObject(geoMechView);
|
||||
geomCase->geoMechViews().removeChildObject(copyOfGeoMechView);
|
||||
|
||||
delete copyOfGeoMechView;
|
||||
}
|
||||
|
||||
delete copyOfView;
|
||||
}
|
||||
|
||||
// Set view back to initial state
|
||||
@ -179,6 +169,36 @@ void RicExportMultipleSnapshotsFeature::exportMultipleSnapshots(const QString& f
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicExportMultipleSnapshotsFeature::exportResultVariations(RimView* rimView, RimMultiSnapshotDefinition* msd, const QString& folder)
|
||||
{
|
||||
exportViewVariationsToFolder(rimView, msd, folder);
|
||||
|
||||
if (msd->selectedEclipseResults().size() > 0)
|
||||
{
|
||||
RimEclipseCase* eclCase = dynamic_cast<RimEclipseCase*>(rimView->ownerCase());
|
||||
|
||||
RimEclipseView* copyOfView = eclCase->createCopyAndAddView(dynamic_cast<RimEclipseView*>(rimView));
|
||||
|
||||
copyOfView->cellResult()->setResultType(msd->eclipseResultType());
|
||||
|
||||
for (QString s : msd->selectedEclipseResults())
|
||||
{
|
||||
copyOfView->cellResult()->setResultVariable(s);
|
||||
|
||||
copyOfView->loadDataAndUpdate();
|
||||
|
||||
exportViewVariationsToFolder(copyOfView, msd, folder);
|
||||
}
|
||||
|
||||
eclCase->reservoirViews().removeChildObject(copyOfView);
|
||||
|
||||
delete copyOfView;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -201,6 +221,11 @@ void RicExportMultipleSnapshotsFeature::exportViewVariationsToFolder(RimView* ri
|
||||
|
||||
if (viewer)
|
||||
{
|
||||
// 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();
|
||||
|
||||
viewer->setCurrentFrame(i);
|
||||
viewer->animationControl()->setCurrentFrameOnly(i);
|
||||
}
|
||||
@ -211,8 +236,6 @@ void RicExportMultipleSnapshotsFeature::exportViewVariationsToFolder(RimView* ri
|
||||
fileName.replace(" ", "-");
|
||||
QString absoluteFileName = caf::Utils::constructFullFileName(folder, fileName, ".png");
|
||||
|
||||
QCoreApplication::instance()->processEvents();
|
||||
|
||||
RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, rimView);
|
||||
}
|
||||
else
|
||||
@ -247,9 +270,7 @@ void RicExportMultipleSnapshotsFeature::exportViewVariationsToFolder(RimView* ri
|
||||
}
|
||||
|
||||
rimView->rangeFilterCollection()->updateDisplayModeNotifyManagedViews(rangeFilter);
|
||||
// Make sure the redraw is processed
|
||||
QCoreApplication::instance()->processEvents();
|
||||
|
||||
|
||||
QString absoluteFileName = caf::Utils::constructFullFileName(folder, fileName, ".png");
|
||||
RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, rimView);
|
||||
}
|
||||
|
@ -39,6 +39,8 @@ protected:
|
||||
public:
|
||||
static void exportMultipleSnapshots(const QString& folder, RimProject* project);
|
||||
|
||||
static void exportResultVariations(RimView* rimView, RimMultiSnapshotDefinition* msd, const QString& folder);
|
||||
|
||||
private:
|
||||
static void exportViewVariationsToFolder(RimView* rimView, RimMultiSnapshotDefinition* msd, const QString& folder);
|
||||
static QString resultName(RimView* rimView);
|
||||
|
@ -156,19 +156,44 @@ void RimEclipseCase::initAfterRead()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipseView* RimEclipseCase::createAndAddReservoirView()
|
||||
{
|
||||
RimEclipseView* riv = new RimEclipseView();
|
||||
riv->setEclipseCase(this);
|
||||
riv->cellEdgeResult()->setResultVariable("MULT");
|
||||
riv->cellEdgeResult()->enableCellEdgeColors = false;
|
||||
RimEclipseView* rimEclipseView = new RimEclipseView();
|
||||
rimEclipseView->setEclipseCase(this);
|
||||
rimEclipseView->cellEdgeResult()->setResultVariable("MULT");
|
||||
rimEclipseView->cellEdgeResult()->enableCellEdgeColors = false;
|
||||
|
||||
caf::PdmDocument::updateUiIconStateRecursively(riv);
|
||||
caf::PdmDocument::updateUiIconStateRecursively(rimEclipseView);
|
||||
|
||||
size_t i = reservoirViews().size();
|
||||
riv->name = QString("View %1").arg(i + 1);
|
||||
rimEclipseView->name = QString("View %1").arg(i + 1);
|
||||
|
||||
reservoirViews().push_back(riv);
|
||||
reservoirViews().push_back(rimEclipseView);
|
||||
|
||||
return riv;
|
||||
return rimEclipseView;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipseView* RimEclipseCase::createCopyAndAddView(const RimEclipseView* sourceView)
|
||||
{
|
||||
CVF_ASSERT(sourceView);
|
||||
|
||||
RimEclipseView* rimEclipseView = dynamic_cast<RimEclipseView*>(sourceView->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
|
||||
CVF_ASSERT(rimEclipseView);
|
||||
|
||||
rimEclipseView->setEclipseCase(this);
|
||||
|
||||
caf::PdmDocument::updateUiIconStateRecursively(rimEclipseView);
|
||||
|
||||
reservoirViews().push_back(rimEclipseView);
|
||||
|
||||
// Resolve references after reservoir view has been inserted into Rim structures
|
||||
// Intersections referencing a well path/ simulation well requires this
|
||||
// TODO: initAfterReadRecursively can probably be removed
|
||||
rimEclipseView->initAfterReadRecursively();
|
||||
rimEclipseView->resolveReferencesRecursively();
|
||||
|
||||
return rimEclipseView;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -74,6 +74,7 @@ public:
|
||||
RimReservoirCellResultsStorage* results(RifReaderInterface::PorosityModelResultType porosityModel);
|
||||
|
||||
RimEclipseView* createAndAddReservoirView();
|
||||
RimEclipseView* createCopyAndAddView(const RimEclipseView* sourceView);
|
||||
|
||||
void removeResult(const QString& resultName);
|
||||
|
||||
|
@ -21,10 +21,13 @@
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RigActiveCellInfo.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimReservoirCellResultsStorage.h"
|
||||
#include "RimView.h"
|
||||
|
||||
#include "cafPdmPointer.h"
|
||||
@ -54,6 +57,10 @@ RimMultiSnapshotDefinition::RimMultiSnapshotDefinition()
|
||||
CAF_PDM_InitObject("MultiSnapshotDefinition", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&viewObject, "View", "View", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&eclipseResultType, "EclipseResultType", "Eclipse Result Type", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&selectedEclipseResults, "SelectedEclipseResults", "Eclipse Result", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&timeStepStart, "TimeStepStart", 0, "Timestep Start", "", "", "");
|
||||
CAF_PDM_InitField(&timeStepEnd, "TimeStepEnd", 0, "Timestep End", "", "", "");
|
||||
|
||||
@ -104,6 +111,23 @@ QList<caf::PdmOptionItemInfo> RimMultiSnapshotDefinition::calculateValueOptions(
|
||||
}
|
||||
options.push_back(caf::PdmOptionItemInfo("-- All views --", nullptr));
|
||||
}
|
||||
else if (fieldNeedingOptions == &eclipseResultType)
|
||||
{
|
||||
options.push_back(caf::PdmOptionItemInfo(caf::AppEnum<RimDefines::ResultCatType>(RimDefines::DYNAMIC_NATIVE).uiText(), RimDefines::DYNAMIC_NATIVE));
|
||||
options.push_back(caf::PdmOptionItemInfo(caf::AppEnum<RimDefines::ResultCatType>(RimDefines::STATIC_NATIVE).uiText(), RimDefines::STATIC_NATIVE));
|
||||
}
|
||||
else if (fieldNeedingOptions == &selectedEclipseResults)
|
||||
{
|
||||
RimView* rimView = viewObject();
|
||||
if (dynamic_cast<RimEclipseView*>(rimView))
|
||||
{
|
||||
RimEclipseView* rimEclipseView = dynamic_cast<RimEclipseView*>(rimView);
|
||||
QStringList varList;
|
||||
varList = rimEclipseView->currentGridCellResults()->cellResults()->resultNames(eclipseResultType());
|
||||
|
||||
options = toOptionList(varList);
|
||||
}
|
||||
}
|
||||
else if (fieldNeedingOptions == &timeStepEnd)
|
||||
{
|
||||
getTimeStepStrings(options);
|
||||
@ -123,9 +147,10 @@ QList<caf::PdmOptionItemInfo> RimMultiSnapshotDefinition::calculateValueOptions(
|
||||
options.push_back(caf::PdmOptionItemInfo(rimCase->caseUserDescription(), rimCase));
|
||||
}
|
||||
|
||||
if (useOptionsOnly) *useOptionsOnly = true;
|
||||
}
|
||||
|
||||
if (useOptionsOnly) *useOptionsOnly = true;
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
@ -149,8 +174,11 @@ void RimMultiSnapshotDefinition::getTimeStepStrings(QList<caf::PdmOptionItemInfo
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimMultiSnapshotDefinition::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
||||
{
|
||||
|
||||
if (changedField == &sliceDirection)
|
||||
if (changedField == &eclipseResultType)
|
||||
{
|
||||
selectedEclipseResults.v().clear();
|
||||
}
|
||||
else if (changedField == &sliceDirection)
|
||||
{
|
||||
const cvf::StructGridInterface* mainGrid = nullptr;
|
||||
RigActiveCellInfo* actCellInfo = nullptr;
|
||||
@ -203,3 +231,16 @@ void RimMultiSnapshotDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo> RimMultiSnapshotDefinition::toOptionList(const QStringList& varList)
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> optionList;
|
||||
int i;
|
||||
for (i = 0; i < varList.size(); ++i)
|
||||
{
|
||||
optionList.push_back(caf::PdmOptionItemInfo(varList[i], varList[i]));
|
||||
}
|
||||
return optionList;
|
||||
}
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RimDefines.h"
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
@ -40,6 +42,9 @@ public:
|
||||
|
||||
caf::PdmPtrField<RimView*> viewObject;
|
||||
|
||||
caf::PdmField< caf::AppEnum< RimDefines::ResultCatType > > eclipseResultType;
|
||||
caf::PdmField< std::vector<QString> > selectedEclipseResults;
|
||||
|
||||
caf::PdmField<int> timeStepStart;
|
||||
caf::PdmField<int> timeStepEnd;
|
||||
|
||||
@ -57,10 +62,12 @@ public:
|
||||
|
||||
caf::PdmPtrArrayField<RimCase*> additionalCases;
|
||||
|
||||
|
||||
private:
|
||||
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;
|
||||
|
||||
void getTimeStepStrings(QList<caf::PdmOptionItemInfo> &options);
|
||||
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
|
||||
QList<caf::PdmOptionItemInfo> toOptionList(const QStringList& varList);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user