mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1018 Added saving of snapshots to loop infrastructure already established
This commit is contained in:
@@ -19,19 +19,26 @@
|
||||
#include "RicExportMultipleSnapshotsFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RicSnapshotViewToClipboardFeature.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RimCellRangeFilter.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimMultiSnapshotDefinition.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimView.h"
|
||||
|
||||
#include "RiuExportMultipleSnapshotsWidget.h"
|
||||
#include "RiuViewer.h"
|
||||
|
||||
#include "cafCmdExecCommandManager.h"
|
||||
#include "cafFrameAnimationControl.h"
|
||||
#include "cafUtils.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QDebug>
|
||||
#include "QDir"
|
||||
#include <QDir>
|
||||
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicExportMultipleSnapshotsFeature, "RicExportMultipleSnapshotsFeature");
|
||||
@@ -78,7 +85,7 @@ void RicExportMultipleSnapshotsFeature::setupActionLook(QAction* actionToSetup)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicExportMultipleSnapshotsFeature::exportMultipleSnapshots(const QString& folder, RimProject* project)
|
||||
{
|
||||
if (!project) return; //Er dette OK syntax??
|
||||
if (!project) return;
|
||||
|
||||
QDir snapshotPath(folder);
|
||||
if (!snapshotPath.exists())
|
||||
@@ -104,54 +111,75 @@ void RicExportMultipleSnapshotsFeature::exportMultipleSnapshots(const QString& f
|
||||
if (activeView && activeView->viewer())
|
||||
{
|
||||
timeSteps = activeCase->timeStepStrings();
|
||||
RiuViewer* viewer = activeView->viewer();
|
||||
int initialFramIndex = viewer->currentFrameIndex();
|
||||
|
||||
for (int i=msd->timeStepStart(); i <= msd->timeStepEnd(); i++)
|
||||
{
|
||||
//TODO: This naming will not give images in the correct order when sorted on name..
|
||||
timeStepString = timeSteps[i].replace(".", "-");
|
||||
|
||||
viewer->setCurrentFrame(i);
|
||||
viewer->animationControl()->setCurrentFrameOnly(i);
|
||||
|
||||
if (msd->sliceDirection == RimMultiSnapshotDefinition::NO_RANGEFILTER)
|
||||
{
|
||||
QString fileName = activeCase->caseUserDescription() + "_" + activeView->name() + "_" + timeStepString + ".png";
|
||||
QString fileName = activeCase->caseUserDescription() + "_" + activeView->name() + "_" + timeStepString;
|
||||
fileName.replace(" ", "-");
|
||||
|
||||
//TODO: Before saveSnapshotAs is called the folder name must be changed from dummy value in widget
|
||||
QString absoluteFileName = caf::Utils::constructFullFileName(folder, fileName, ".png");
|
||||
//RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, activeView);
|
||||
|
||||
qDebug() << absoluteFileName;
|
||||
|
||||
RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, activeView);
|
||||
}
|
||||
else
|
||||
{
|
||||
RimCellRangeFilter* rangeFilter = new RimCellRangeFilter;
|
||||
activeView->rangeFilterCollection()->rangeFilters.push_back(rangeFilter);
|
||||
|
||||
bool rangeFilterInitState = activeView->rangeFilterCollection()->isActive();
|
||||
activeView->rangeFilterCollection()->isActive = true;
|
||||
|
||||
for (int i = msd->startSliceIndex(); i <= msd->endSliceIndex(); i++)
|
||||
{
|
||||
rangeFilterString = msd->sliceDirection().text() + QString::number(i);
|
||||
|
||||
// setActiveReservoirView(riv);
|
||||
// RiuViewer* viewer = riv->viewer();
|
||||
// mainWnd->setActiveViewer(viewer->layoutWidget());
|
||||
// clearViewsScheduledForUpdate();
|
||||
// //riv->updateCurrentTimeStepAndRedraw();
|
||||
// riv->createDisplayModelAndRedraw();
|
||||
// viewer->repaint();
|
||||
// for (int i=msd->timeStepStart(); i<msd->timeStepEnd(); i++)
|
||||
|
||||
|
||||
QString fileName = activeCase->caseUserDescription() + "_" + activeView->name() + "_" + timeStepString + "_" + rangeFilterString + ".png";
|
||||
QString fileName = activeCase->caseUserDescription() + "_" + activeView->name() + "_" + timeStepString + "_" + rangeFilterString;
|
||||
fileName.replace(" ", "-");
|
||||
|
||||
//TODO: Before saveSnapshotAs is called the folder name must be changed from dummy value in widget
|
||||
rangeFilter->setDefaultValues();
|
||||
if (msd->sliceDirection == RimMultiSnapshotDefinition::RANGEFILTER_I)
|
||||
{
|
||||
rangeFilter->cellCountI = 1;
|
||||
rangeFilter->startIndexI = i;
|
||||
}
|
||||
else if (msd->sliceDirection == RimMultiSnapshotDefinition::RANGEFILTER_J)
|
||||
{
|
||||
rangeFilter->cellCountJ = 1;
|
||||
rangeFilter->startIndexJ = i;
|
||||
}
|
||||
else if (msd->sliceDirection == RimMultiSnapshotDefinition::RANGEFILTER_K)
|
||||
{
|
||||
rangeFilter->cellCountK = 1;
|
||||
rangeFilter->startIndexK = i;
|
||||
}
|
||||
|
||||
activeView->rangeFilterCollection()->updateDisplayModeNotifyManagedViews(rangeFilter);
|
||||
// Make sure the redraw is processed
|
||||
QCoreApplication::instance()->processEvents();
|
||||
|
||||
QString absoluteFileName = caf::Utils::constructFullFileName(folder, fileName, ".png");
|
||||
//RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, activeView);
|
||||
|
||||
qDebug() << absoluteFileName;
|
||||
|
||||
|
||||
RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, activeView);
|
||||
}
|
||||
|
||||
}
|
||||
activeView->rangeFilterCollection()->rangeFilters.removeChildObject(rangeFilter);
|
||||
delete rangeFilter;
|
||||
|
||||
activeView->rangeFilterCollection()->isActive = rangeFilterInitState;
|
||||
activeView->scheduleCreateDisplayModelAndRedraw();
|
||||
QCoreApplication::instance()->processEvents();
|
||||
}
|
||||
}
|
||||
|
||||
viewer->setCurrentFrame(initialFramIndex);
|
||||
viewer->animationControl()->setCurrentFrameOnly(initialFramIndex);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user