mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-10 08:03:05 -06:00
#1018 Added option for taking snapshots of all cases
This commit is contained in:
parent
2ee20257a8
commit
8ce9c2300f
@ -100,35 +100,70 @@ void RicExportMultipleSnapshotsFeature::exportMultipleSnapshots(const QString& f
|
||||
QString timeStepString;
|
||||
QString rangeFilterString;
|
||||
|
||||
std::vector<RimView*> ViewsToPlot;
|
||||
std::vector<RimCase*> casesToPlot;
|
||||
std::vector<std::pair<RimCase*, RimView*>> casesViewsPairs;
|
||||
|
||||
|
||||
for (RimMultiSnapshotDefinition* msd : project->multiSnapshotDefinitions())
|
||||
{
|
||||
|
||||
activeCase = msd->caseObject();
|
||||
if (!activeCase) continue;
|
||||
|
||||
activeView = msd->viewObject();
|
||||
|
||||
if (activeView)
|
||||
if (activeCase)
|
||||
{
|
||||
ViewsToPlot.push_back(activeView);
|
||||
casesToPlot.push_back(activeCase);
|
||||
}
|
||||
else //nullptr is value used for "All"
|
||||
{
|
||||
for (RimView* view : activeCase->views())
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
std::vector<RimCase*> cases;
|
||||
proj->allCases(cases);
|
||||
|
||||
for (RimCase* thisCase : cases)
|
||||
{
|
||||
ViewsToPlot.push_back(view);
|
||||
casesToPlot.push_back(thisCase);
|
||||
}
|
||||
}
|
||||
|
||||
for (RimView* thisView : ViewsToPlot)
|
||||
|
||||
for (RimCase* rimCase : casesToPlot)
|
||||
{
|
||||
if (thisView && thisView->viewer())
|
||||
activeView = msd->viewObject();
|
||||
|
||||
if (activeView)
|
||||
{
|
||||
timeSteps = activeCase->timeStepStrings();
|
||||
RiuViewer* viewer = thisView->viewer();
|
||||
casesViewsPairs.push_back(std::make_pair(rimCase, activeView));
|
||||
|
||||
}
|
||||
else //nullptr is value used for "All"
|
||||
{
|
||||
for (RimView* rimView : rimCase->views())
|
||||
{
|
||||
casesViewsPairs.push_back(std::make_pair(rimCase, rimView));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RimView* rimView = nullptr;
|
||||
RimCase* rimCase = nullptr;
|
||||
bool pairExists = false;
|
||||
|
||||
for (auto caseViewPair : casesViewsPairs)
|
||||
{
|
||||
rimCase = caseViewPair.first;
|
||||
rimView = caseViewPair.second;
|
||||
pairExists = false;
|
||||
|
||||
for (auto viewToCheck : rimCase->views())
|
||||
{
|
||||
if (viewToCheck == rimView) pairExists = true;
|
||||
}
|
||||
|
||||
if (pairExists && rimView && rimView->viewer())
|
||||
{
|
||||
timeSteps = rimCase->timeStepStrings();
|
||||
RiuViewer* viewer = rimView->viewer();
|
||||
int initialFramIndex = viewer->currentFrameIndex();
|
||||
|
||||
for (int i = msd->timeStepStart(); i <= msd->timeStepEnd(); i++)
|
||||
@ -142,23 +177,23 @@ void RicExportMultipleSnapshotsFeature::exportMultipleSnapshots(const QString& f
|
||||
|
||||
if (msd->sliceDirection == RimMultiSnapshotDefinition::NO_RANGEFILTER)
|
||||
{
|
||||
QString fileName = activeCase->caseUserDescription() + "_" + thisView->name() + "_" + timeStepString;
|
||||
QString fileName = rimCase->caseUserDescription() + "_" + rimView->name() + "_" + timeStepString;
|
||||
fileName.replace(" ", "-");
|
||||
QString absoluteFileName = caf::Utils::constructFullFileName(folder, fileName, ".png");
|
||||
RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, thisView);
|
||||
RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, rimView);
|
||||
}
|
||||
else
|
||||
{
|
||||
RimCellRangeFilter* rangeFilter = new RimCellRangeFilter;
|
||||
thisView->rangeFilterCollection()->rangeFilters.push_back(rangeFilter);
|
||||
rimView->rangeFilterCollection()->rangeFilters.push_back(rangeFilter);
|
||||
|
||||
bool rangeFilterInitState = thisView->rangeFilterCollection()->isActive();
|
||||
thisView->rangeFilterCollection()->isActive = true;
|
||||
bool rangeFilterInitState = rimView->rangeFilterCollection()->isActive();
|
||||
rimView->rangeFilterCollection()->isActive = true;
|
||||
|
||||
for (int i = msd->startSliceIndex(); i <= msd->endSliceIndex(); i++)
|
||||
{
|
||||
rangeFilterString = msd->sliceDirection().text() + "-" + QString::number(i);
|
||||
QString fileName = activeCase->caseUserDescription() + "_" + thisView->name() + "_" + timeStepString + "_" + rangeFilterString;
|
||||
QString fileName = rimCase->caseUserDescription() + "_" + rimView->name() + "_" + timeStepString + "_" + rangeFilterString;
|
||||
fileName.replace(" ", "-");
|
||||
|
||||
rangeFilter->setDefaultValues();
|
||||
@ -178,19 +213,19 @@ void RicExportMultipleSnapshotsFeature::exportMultipleSnapshots(const QString& f
|
||||
rangeFilter->startIndexK = i;
|
||||
}
|
||||
|
||||
thisView->rangeFilterCollection()->updateDisplayModeNotifyManagedViews(rangeFilter);
|
||||
rimView->rangeFilterCollection()->updateDisplayModeNotifyManagedViews(rangeFilter);
|
||||
// Make sure the redraw is processed
|
||||
QCoreApplication::instance()->processEvents();
|
||||
|
||||
QString absoluteFileName = caf::Utils::constructFullFileName(folder, fileName, ".png");
|
||||
RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, thisView);
|
||||
RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, rimView);
|
||||
}
|
||||
|
||||
thisView->rangeFilterCollection()->rangeFilters.removeChildObject(rangeFilter);
|
||||
rimView->rangeFilterCollection()->rangeFilters.removeChildObject(rangeFilter);
|
||||
delete rangeFilter;
|
||||
|
||||
thisView->rangeFilterCollection()->isActive = rangeFilterInitState;
|
||||
thisView->scheduleCreateDisplayModelAndRedraw();
|
||||
rimView->rangeFilterCollection()->isActive = rangeFilterInitState;
|
||||
rimView->scheduleCreateDisplayModelAndRedraw();
|
||||
QCoreApplication::instance()->processEvents();
|
||||
}
|
||||
}
|
||||
@ -199,12 +234,7 @@ void RicExportMultipleSnapshotsFeature::exportMultipleSnapshots(const QString& f
|
||||
viewer->animationControl()->setCurrentFrameOnly(initialFramIndex);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -94,33 +94,48 @@ QList<caf::PdmOptionItemInfo> RimMultiSnapshotDefinition::calculateValueOptions(
|
||||
// TODO: Update to simpler implementation
|
||||
}
|
||||
|
||||
//options.push_back(caf::PdmOptionItemInfo("All", QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(nullptr))));
|
||||
options.push_back(caf::PdmOptionItemInfo("-- All cases --", QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(nullptr))));
|
||||
}
|
||||
else if (fieldNeedingOptions == &viewObject)
|
||||
{
|
||||
std::vector<RimView*> views;
|
||||
|
||||
if (caseObject())
|
||||
{
|
||||
std::vector<RimView*> views = caseObject()->views();
|
||||
for (RimView* view : views)
|
||||
views = caseObject()->views();
|
||||
}
|
||||
else
|
||||
{
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
std::vector<RimCase*> cases;
|
||||
proj->allCases(cases);
|
||||
|
||||
if (cases.size() > 0)
|
||||
{
|
||||
options.push_back(caf::PdmOptionItemInfo(view->name(), QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(view))));
|
||||
//options.push_back(caf::PdmOptionItemInfo(view->name(), view));
|
||||
RimCase* rimCase = cases[0];
|
||||
if (rimCase->views().size() > 0)
|
||||
{
|
||||
views = rimCase->views();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (RimView* view : views)
|
||||
{
|
||||
options.push_back(caf::PdmOptionItemInfo(view->name(), QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(view))));
|
||||
//options.push_back(caf::PdmOptionItemInfo(view->name(), view));
|
||||
}
|
||||
options.push_back(caf::PdmOptionItemInfo("-- All views --", QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(nullptr))));
|
||||
}
|
||||
else if (fieldNeedingOptions == &timeStepEnd)
|
||||
{
|
||||
getTimeStepStrings(options);
|
||||
|
||||
}
|
||||
else if (fieldNeedingOptions == &timeStepStart)
|
||||
{
|
||||
getTimeStepStrings(options);
|
||||
}
|
||||
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
@ -129,14 +144,33 @@ QList<caf::PdmOptionItemInfo> RimMultiSnapshotDefinition::calculateValueOptions(
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimMultiSnapshotDefinition::getTimeStepStrings(QList<caf::PdmOptionItemInfo> &options)
|
||||
{
|
||||
if (!caseObject()) return;
|
||||
|
||||
QStringList timeSteps = caseObject()->timeStepStrings();
|
||||
QStringList timeSteps;
|
||||
|
||||
if (!caseObject())
|
||||
{
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
std::vector<RimCase*> cases;
|
||||
proj->allCases(cases);
|
||||
|
||||
if (cases.size() > 0)
|
||||
{
|
||||
RimCase* rimCase = cases[0];
|
||||
if (rimCase->views().size() > 0)
|
||||
{
|
||||
timeSteps = rimCase->timeStepStrings();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
timeSteps = caseObject()->timeStepStrings();
|
||||
}
|
||||
|
||||
for (int i = 0; i < timeSteps.size(); i++)
|
||||
{
|
||||
options.push_back(caf::PdmOptionItemInfo(timeSteps[i], i));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -144,6 +178,7 @@ void RimMultiSnapshotDefinition::getTimeStepStrings(QList<caf::PdmOptionItemInfo
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimMultiSnapshotDefinition::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
||||
{
|
||||
|
||||
if (changedField == &sliceDirection)
|
||||
{
|
||||
const cvf::StructGridInterface* mainGrid = nullptr;
|
||||
|
Loading…
Reference in New Issue
Block a user