#1018 Snapshot - Added support for multiple result variables

This commit is contained in:
Magne Sjaastad
2016-12-22 08:45:30 +01:00
parent ebf5b01234
commit 4515579d52
6 changed files with 143 additions and 46 deletions

View File

@@ -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);
}

View File

@@ -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);