mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1018 Added option for taking snapshots of all views.
This commit is contained in:
@@ -100,6 +100,9 @@ void RicExportMultipleSnapshotsFeature::exportMultipleSnapshots(const QString& f
|
||||
QString timeStepString;
|
||||
QString rangeFilterString;
|
||||
|
||||
std::vector<RimView*> ViewsToPlot;
|
||||
|
||||
|
||||
for (RimMultiSnapshotDefinition* msd : project->multiSnapshotDefinitions())
|
||||
{
|
||||
|
||||
@@ -108,81 +111,101 @@ void RicExportMultipleSnapshotsFeature::exportMultipleSnapshots(const QString& f
|
||||
|
||||
activeView = msd->viewObject();
|
||||
|
||||
if (activeView && activeView->viewer())
|
||||
if (activeView)
|
||||
{
|
||||
timeSteps = activeCase->timeStepStrings();
|
||||
RiuViewer* viewer = activeView->viewer();
|
||||
int initialFramIndex = viewer->currentFrameIndex();
|
||||
|
||||
for (int i=msd->timeStepStart(); i <= msd->timeStepEnd(); i++)
|
||||
ViewsToPlot.push_back(activeView);
|
||||
}
|
||||
else //nullptr is value used for "All"
|
||||
{
|
||||
for (RimView* view : activeCase->views())
|
||||
{
|
||||
QString timeStepIndexString = QString("%1").arg(i, 2, 10, QLatin1Char('0'));
|
||||
ViewsToPlot.push_back(view);
|
||||
}
|
||||
}
|
||||
|
||||
timeStepString = timeStepIndexString + "_" + timeSteps[i].replace(".", "-");
|
||||
|
||||
viewer->setCurrentFrame(i);
|
||||
viewer->animationControl()->setCurrentFrameOnly(i);
|
||||
for (RimView* thisView : ViewsToPlot)
|
||||
{
|
||||
if (thisView && thisView->viewer())
|
||||
{
|
||||
timeSteps = activeCase->timeStepStrings();
|
||||
RiuViewer* viewer = thisView->viewer();
|
||||
int initialFramIndex = viewer->currentFrameIndex();
|
||||
|
||||
if (msd->sliceDirection == RimMultiSnapshotDefinition::NO_RANGEFILTER)
|
||||
for (int i = msd->timeStepStart(); i <= msd->timeStepEnd(); i++)
|
||||
{
|
||||
QString fileName = activeCase->caseUserDescription() + "_" + activeView->name() + "_" + timeStepString;
|
||||
fileName.replace(" ", "-");
|
||||
QString absoluteFileName = caf::Utils::constructFullFileName(folder, fileName, ".png");
|
||||
RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, activeView);
|
||||
}
|
||||
else
|
||||
{
|
||||
RimCellRangeFilter* rangeFilter = new RimCellRangeFilter;
|
||||
activeView->rangeFilterCollection()->rangeFilters.push_back(rangeFilter);
|
||||
QString timeStepIndexString = QString("%1").arg(i, 2, 10, QLatin1Char('0'));
|
||||
|
||||
bool rangeFilterInitState = activeView->rangeFilterCollection()->isActive();
|
||||
activeView->rangeFilterCollection()->isActive = true;
|
||||
timeStepString = timeStepIndexString + "_" + timeSteps[i].replace(".", "-");
|
||||
|
||||
for (int i = msd->startSliceIndex(); i <= msd->endSliceIndex(); i++)
|
||||
viewer->setCurrentFrame(i);
|
||||
viewer->animationControl()->setCurrentFrameOnly(i);
|
||||
|
||||
if (msd->sliceDirection == RimMultiSnapshotDefinition::NO_RANGEFILTER)
|
||||
{
|
||||
rangeFilterString = msd->sliceDirection().text() + "-" + QString::number(i);
|
||||
QString fileName = activeCase->caseUserDescription() + "_" + activeView->name() + "_" + timeStepString + "_" + rangeFilterString;
|
||||
QString fileName = activeCase->caseUserDescription() + "_" + thisView->name() + "_" + timeStepString;
|
||||
fileName.replace(" ", "-");
|
||||
|
||||
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);
|
||||
RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, thisView);
|
||||
}
|
||||
else
|
||||
{
|
||||
RimCellRangeFilter* rangeFilter = new RimCellRangeFilter;
|
||||
thisView->rangeFilterCollection()->rangeFilters.push_back(rangeFilter);
|
||||
|
||||
activeView->rangeFilterCollection()->rangeFilters.removeChildObject(rangeFilter);
|
||||
delete rangeFilter;
|
||||
bool rangeFilterInitState = thisView->rangeFilterCollection()->isActive();
|
||||
thisView->rangeFilterCollection()->isActive = true;
|
||||
|
||||
activeView->rangeFilterCollection()->isActive = rangeFilterInitState;
|
||||
activeView->scheduleCreateDisplayModelAndRedraw();
|
||||
QCoreApplication::instance()->processEvents();
|
||||
for (int i = msd->startSliceIndex(); i <= msd->endSliceIndex(); i++)
|
||||
{
|
||||
rangeFilterString = msd->sliceDirection().text() + "-" + QString::number(i);
|
||||
QString fileName = activeCase->caseUserDescription() + "_" + thisView->name() + "_" + timeStepString + "_" + rangeFilterString;
|
||||
fileName.replace(" ", "-");
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
thisView->rangeFilterCollection()->updateDisplayModeNotifyManagedViews(rangeFilter);
|
||||
// Make sure the redraw is processed
|
||||
QCoreApplication::instance()->processEvents();
|
||||
|
||||
QString absoluteFileName = caf::Utils::constructFullFileName(folder, fileName, ".png");
|
||||
RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, thisView);
|
||||
}
|
||||
|
||||
thisView->rangeFilterCollection()->rangeFilters.removeChildObject(rangeFilter);
|
||||
delete rangeFilter;
|
||||
|
||||
thisView->rangeFilterCollection()->isActive = rangeFilterInitState;
|
||||
thisView->scheduleCreateDisplayModelAndRedraw();
|
||||
QCoreApplication::instance()->processEvents();
|
||||
}
|
||||
}
|
||||
|
||||
viewer->setCurrentFrame(initialFramIndex);
|
||||
viewer->animationControl()->setCurrentFrameOnly(initialFramIndex);
|
||||
|
||||
}
|
||||
|
||||
viewer->setCurrentFrame(initialFramIndex);
|
||||
viewer->animationControl()->setCurrentFrameOnly(initialFramIndex);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -19,13 +19,15 @@
|
||||
#include "RimMultiSnapshotDefinition.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RigActiveCellInfo.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimView.h"
|
||||
|
||||
#include "cafPdmPointer.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RigActiveCellInfo.h"
|
||||
|
||||
namespace caf
|
||||
{
|
||||
@@ -56,7 +58,7 @@ RimMultiSnapshotDefinition::RimMultiSnapshotDefinition()
|
||||
CAF_PDM_InitField(&timeStepStart, "TimeStepStart", 0, "Timestep Start", "", "", "");
|
||||
CAF_PDM_InitField(&timeStepEnd, "TimeStepEnd", 0, "Timestep End", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&sliceDirection, "SnapShotDirection", caf::AppEnum<SnapShotDirectionEnum>(RANGEFILTER_K), "Range Filter direction", "", "", "");
|
||||
CAF_PDM_InitField(&sliceDirection, "SnapShotDirection", caf::AppEnum<SnapShotDirectionEnum>(NO_RANGEFILTER), "Range Filter direction", "", "", "");
|
||||
CAF_PDM_InitField(&startSliceIndex, "RangeFilterStart", 1, "RangeFilter Start", "", "", "");
|
||||
CAF_PDM_InitField(&endSliceIndex, "RangeFilterEnd", 1, "RangeFilter End", "", "", "");
|
||||
|
||||
@@ -106,7 +108,7 @@ QList<caf::PdmOptionItemInfo> RimMultiSnapshotDefinition::calculateValueOptions(
|
||||
}
|
||||
}
|
||||
|
||||
//options.push_back(caf::PdmOptionItemInfo("All", QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(nullptr))));
|
||||
options.push_back(caf::PdmOptionItemInfo("-- All views --", QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(nullptr))));
|
||||
}
|
||||
else if (fieldNeedingOptions == &timeStepEnd)
|
||||
{
|
||||
@@ -144,50 +146,69 @@ void RimMultiSnapshotDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha
|
||||
{
|
||||
if (changedField == &sliceDirection)
|
||||
{
|
||||
const cvf::StructGridInterface* mainGrid = nullptr;
|
||||
RigActiveCellInfo* actCellInfo = nullptr;
|
||||
|
||||
if (!viewObject()) {
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
std::vector<RimCase*> cases;
|
||||
proj->allCases(cases);
|
||||
|
||||
if (cases.size() > 0)
|
||||
{
|
||||
RimCase* activeCase = cases[0];
|
||||
if (activeCase->views().size() > 0)
|
||||
{
|
||||
RimView* firstView = activeCase->views()[0];
|
||||
mainGrid = firstView->rangeFilterCollection()->gridByIndex(0);
|
||||
actCellInfo = firstView->rangeFilterCollection()->activeCellInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (viewObject())
|
||||
{
|
||||
const cvf::StructGridInterface* mainGrid = viewObject()->rangeFilterCollection()->gridByIndex(0);
|
||||
mainGrid = viewObject()->rangeFilterCollection()->gridByIndex(0);
|
||||
actCellInfo = viewObject()->rangeFilterCollection()->activeCellInfo();
|
||||
}
|
||||
|
||||
RigActiveCellInfo* actCellInfo = viewObject()->rangeFilterCollection()->activeCellInfo();
|
||||
if (mainGrid && actCellInfo)
|
||||
if (mainGrid && actCellInfo)
|
||||
{
|
||||
cvf::Vec3st min, max;
|
||||
actCellInfo->IJKBoundingBox(min, max);
|
||||
|
||||
// Adjust to Eclipse indexing
|
||||
min.x() = min.x() + 1;
|
||||
min.y() = min.y() + 1;
|
||||
min.z() = min.z() + 1;
|
||||
|
||||
max.x() = max.x() + 1;
|
||||
max.y() = max.y() + 1;
|
||||
max.z() = max.z() + 1;
|
||||
|
||||
int maxInt = 0;
|
||||
int minInt = 0;
|
||||
|
||||
if (newValue == RimMultiSnapshotDefinition::RANGEFILTER_I)
|
||||
{
|
||||
cvf::Vec3st min, max;
|
||||
actCellInfo->IJKBoundingBox(min, max);
|
||||
|
||||
// Adjust to Eclipse indexing
|
||||
min.x() = min.x() + 1;
|
||||
min.y() = min.y() + 1;
|
||||
min.z() = min.z() + 1;
|
||||
|
||||
max.x() = max.x() + 1;
|
||||
max.y() = max.y() + 1;
|
||||
max.z() = max.z() + 1;
|
||||
|
||||
int maxInt = 0;
|
||||
int minInt = 0;
|
||||
|
||||
if (newValue == RimMultiSnapshotDefinition::RANGEFILTER_I)
|
||||
{
|
||||
maxInt = static_cast<int>(max.x());
|
||||
minInt = static_cast<int>(min.x());
|
||||
}
|
||||
else if (newValue == RimMultiSnapshotDefinition::RANGEFILTER_J)
|
||||
{
|
||||
maxInt = static_cast<int>(max.y());
|
||||
minInt = static_cast<int>(min.y());
|
||||
}
|
||||
else if (newValue == RimMultiSnapshotDefinition::RANGEFILTER_K)
|
||||
{
|
||||
maxInt = static_cast<int>(max.z());
|
||||
minInt = static_cast<int>(min.z());
|
||||
}
|
||||
maxInt = static_cast<int>(max.x());
|
||||
minInt = static_cast<int>(min.x());
|
||||
}
|
||||
else if (newValue == RimMultiSnapshotDefinition::RANGEFILTER_J)
|
||||
{
|
||||
maxInt = static_cast<int>(max.y());
|
||||
minInt = static_cast<int>(min.y());
|
||||
}
|
||||
else if (newValue == RimMultiSnapshotDefinition::RANGEFILTER_K)
|
||||
{
|
||||
maxInt = static_cast<int>(max.z());
|
||||
minInt = static_cast<int>(min.z());
|
||||
}
|
||||
|
||||
startSliceIndex = minInt;
|
||||
endSliceIndex = maxInt;
|
||||
startSliceIndex = minInt;
|
||||
endSliceIndex = maxInt;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
startSliceIndex.uiCapability()->updateConnectedEditors();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user