mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1018 Added loops for making multiple snapshots based on user input in widget. Filnames are generated, but no images saved yet.
This commit is contained in:
@@ -19,12 +19,19 @@
|
||||
#include "RicExportMultipleSnapshotsFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RicSnapshotViewToClipboardFeature.h"
|
||||
#include "RimCase.h"
|
||||
#include "RimMultiSnapshotDefinition.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimView.h"
|
||||
#include "RiuExportMultipleSnapshotsWidget.h"
|
||||
|
||||
#include "cafCmdExecCommandManager.h"
|
||||
#include "cafUtils.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QDebug>
|
||||
#include "QDir"
|
||||
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicExportMultipleSnapshotsFeature, "RicExportMultipleSnapshotsFeature");
|
||||
@@ -66,3 +73,87 @@ void RicExportMultipleSnapshotsFeature::setupActionLook(QAction* actionToSetup)
|
||||
//actionToSetup->setIcon(QIcon(":/Save.png"));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicExportMultipleSnapshotsFeature::exportMultipleSnapshots(const QString& folder, RimProject* project)
|
||||
{
|
||||
if (!project) return; //Er dette OK syntax??
|
||||
|
||||
QDir snapshotPath(folder);
|
||||
if (!snapshotPath.exists())
|
||||
{
|
||||
if (!snapshotPath.mkpath(".")) return;
|
||||
}
|
||||
|
||||
RimCase* activeCase = nullptr;
|
||||
RimView* activeView = nullptr;
|
||||
|
||||
QStringList timeSteps;
|
||||
QString timeStepString;
|
||||
QString rangeFilterString;
|
||||
|
||||
for (RimMultiSnapshotDefinition* msd : project->multiSnapshotDefinitions())
|
||||
{
|
||||
|
||||
activeCase = msd->caseObject();
|
||||
if (!activeCase) continue;
|
||||
|
||||
activeView = msd->viewObject();
|
||||
|
||||
if (activeView && activeView->viewer())
|
||||
{
|
||||
timeSteps = activeCase->timeStepStrings();
|
||||
|
||||
for (int i=msd->timeStepStart(); i <= msd->timeStepEnd(); i++)
|
||||
{
|
||||
timeStepString = timeSteps[i].replace(".", "-");
|
||||
|
||||
if (msd->sliceDirection == RimMultiSnapshotDefinition::NO_RANGEFILTER)
|
||||
{
|
||||
QString fileName = activeCase->caseUserDescription() + "_" + activeView->name() + "_" + timeStepString + ".png";
|
||||
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;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
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";
|
||||
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;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
class RimProject;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@@ -32,5 +33,8 @@ protected:
|
||||
virtual bool isCommandEnabled() override;
|
||||
virtual void onActionTriggered( bool isChecked ) override;
|
||||
virtual void setupActionLook(QAction* actionToSetup) override;
|
||||
|
||||
public:
|
||||
static void exportMultipleSnapshots(const QString& folder, RimProject* project);
|
||||
};
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace caf
|
||||
addItem(RimMultiSnapshotDefinition::RANGEFILTER_I, "I", "i-direction");
|
||||
addItem(RimMultiSnapshotDefinition::RANGEFILTER_J, "J", "j-direction");
|
||||
addItem(RimMultiSnapshotDefinition::RANGEFILTER_K, "K", "k-direction");
|
||||
addItem(RimMultiSnapshotDefinition::NO_RANGEFILTER, "None", "None");
|
||||
|
||||
setDefault(RimMultiSnapshotDefinition::RANGEFILTER_K);
|
||||
}
|
||||
@@ -54,8 +55,8 @@ RimMultiSnapshotDefinition::RimMultiSnapshotDefinition()
|
||||
CAF_PDM_InitField(&timeStepEnd, "TimeStepEnd", 0, "Timestep End", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&sliceDirection, "SnapShotDirection", caf::AppEnum<SnapShotDirectionEnum>(RANGEFILTER_K), "Range Filter direction", "", "", "");
|
||||
CAF_PDM_InitField(&startSliceIndex, "RangeFilterStart", 0, "RangeFilter Start", "", "", "");
|
||||
CAF_PDM_InitField(&endSliceIndex, "RangeFilterEnd", 0, "RangeFilter End", "", "", "");
|
||||
CAF_PDM_InitField(&startSliceIndex, "RangeFilterStart", 1, "RangeFilter Start", "", "", "");
|
||||
CAF_PDM_InitField(&endSliceIndex, "RangeFilterEnd", 1, "RangeFilter End", "", "", "");
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -47,7 +47,8 @@ public:
|
||||
{
|
||||
RANGEFILTER_I,
|
||||
RANGEFILTER_J,
|
||||
RANGEFILTER_K
|
||||
RANGEFILTER_K,
|
||||
NO_RANGEFILTER
|
||||
};
|
||||
|
||||
caf::PdmField< caf::AppEnum< SnapShotDirectionEnum > > sliceDirection;
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RicExportMultipleSnapshotsFeature.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RimMultiSnapshotDefinition.h"
|
||||
#include "RimProject.h"
|
||||
@@ -164,8 +166,9 @@ void RiuExportMultipleSnapshotsWidget::deleteAllSnapshotItems()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuExportMultipleSnapshotsWidget::exportSnapshots()
|
||||
{
|
||||
// TODO: wire up call of static method
|
||||
// RicExportMultipleSnapshotsFeature::staticMethod()
|
||||
QString dummyFolder = "folder"; //TODO: Must be a real folder before saving images!!!
|
||||
RicExportMultipleSnapshotsFeature::exportMultipleSnapshots(dummyFolder, m_rimProject);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user