mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1730 Include more information in snapshot filenames
This commit is contained in:
@@ -90,6 +90,7 @@
|
|||||||
#include "RicImportSummaryCaseFeature.h"
|
#include "RicImportSummaryCaseFeature.h"
|
||||||
#include "ExportCommands/RicSnapshotViewToFileFeature.h"
|
#include "ExportCommands/RicSnapshotViewToFileFeature.h"
|
||||||
#include "ExportCommands/RicSnapshotAllPlotsToFileFeature.h"
|
#include "ExportCommands/RicSnapshotAllPlotsToFileFeature.h"
|
||||||
|
#include "ExportCommands/RicSnapshotAllViewsToFileFeature.h"
|
||||||
#include "SummaryPlotCommands/RicNewSummaryPlotFeature.h"
|
#include "SummaryPlotCommands/RicNewSummaryPlotFeature.h"
|
||||||
|
|
||||||
#include "RicfCommandFileExecutor.h"
|
#include "RicfCommandFileExecutor.h"
|
||||||
@@ -1575,7 +1576,7 @@ bool RiaApplication::parseArguments()
|
|||||||
// 2016-11-09 : Location of snapshot folder was previously located in 'snapshot' folder
|
// 2016-11-09 : Location of snapshot folder was previously located in 'snapshot' folder
|
||||||
// relative to current working folder. Now harmonized to behave as RiuMainWindow::slotSnapshotAllViewsToFile()
|
// relative to current working folder. Now harmonized to behave as RiuMainWindow::slotSnapshotAllViewsToFile()
|
||||||
QString absolutePathToSnapshotDir = createAbsolutePathFromProjectRelativePath("snapshots");
|
QString absolutePathToSnapshotDir = createAbsolutePathFromProjectRelativePath("snapshots");
|
||||||
saveSnapshotForAllViews(absolutePathToSnapshotDir);
|
RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(absolutePathToSnapshotDir);
|
||||||
|
|
||||||
mainWnd->loadWinGeoAndDockToolBarLayout();
|
mainWnd->loadWinGeoAndDockToolBarLayout();
|
||||||
}
|
}
|
||||||
@@ -2270,62 +2271,6 @@ bool RiaApplication::openFile(const QString& fileName)
|
|||||||
return loadingSucceded;
|
return loadingSucceded;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void RiaApplication::saveSnapshotForAllViews(const QString& snapshotFolderName)
|
|
||||||
{
|
|
||||||
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
|
||||||
if (!mainWnd) return;
|
|
||||||
|
|
||||||
if (m_project.isNull()) return;
|
|
||||||
|
|
||||||
QDir snapshotPath(snapshotFolderName);
|
|
||||||
if (!snapshotPath.exists())
|
|
||||||
{
|
|
||||||
if (!snapshotPath.mkpath(".")) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QString absSnapshotPath = snapshotPath.absolutePath();
|
|
||||||
|
|
||||||
std::vector<RimCase*> projectCases;
|
|
||||||
m_project->allCases(projectCases);
|
|
||||||
|
|
||||||
for (size_t i = 0; i < projectCases.size(); i++)
|
|
||||||
{
|
|
||||||
RimCase* cas = projectCases[i];
|
|
||||||
if (!cas) continue;
|
|
||||||
|
|
||||||
std::vector<RimView*> views = cas->views();
|
|
||||||
|
|
||||||
for (size_t j = 0; j < views.size(); j++)
|
|
||||||
{
|
|
||||||
RimView* riv = views[j];
|
|
||||||
|
|
||||||
if (riv && riv->viewer())
|
|
||||||
{
|
|
||||||
setActiveReservoirView(riv);
|
|
||||||
|
|
||||||
RiuViewer* viewer = riv->viewer();
|
|
||||||
mainWnd->setActiveViewer(viewer->layoutWidget());
|
|
||||||
|
|
||||||
clearViewsScheduledForUpdate();
|
|
||||||
|
|
||||||
//riv->updateCurrentTimeStepAndRedraw();
|
|
||||||
riv->createDisplayModelAndRedraw();
|
|
||||||
viewer->repaint();
|
|
||||||
|
|
||||||
QString fileName = cas->caseUserDescription() + "-" + riv->name();
|
|
||||||
fileName = caf::Utils::makeValidFileBasename(fileName);
|
|
||||||
|
|
||||||
QString absoluteFileName = caf::Utils::constructFullFileName(absSnapshotPath, fileName, ".png");
|
|
||||||
|
|
||||||
RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, riv);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -2347,7 +2292,7 @@ void RiaApplication::runMultiCaseSnapshots(const QString& templateProjectFileNam
|
|||||||
bool loadOk = loadProject(templateProjectFileName, PLA_NONE, &modifier);
|
bool loadOk = loadProject(templateProjectFileName, PLA_NONE, &modifier);
|
||||||
if (loadOk)
|
if (loadOk)
|
||||||
{
|
{
|
||||||
saveSnapshotForAllViews(snapshotFolderName);
|
RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(snapshotFolderName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2492,7 +2437,7 @@ void RiaApplication::runRegressionTest(const QString& testRootPath)
|
|||||||
resizeMaximizedPlotWindows();
|
resizeMaximizedPlotWindows();
|
||||||
|
|
||||||
QString fullPathGeneratedFolder = testCaseFolder.absoluteFilePath(generatedFolderName);
|
QString fullPathGeneratedFolder = testCaseFolder.absoluteFilePath(generatedFolderName);
|
||||||
saveSnapshotForAllViews(fullPathGeneratedFolder);
|
RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(fullPathGeneratedFolder);
|
||||||
|
|
||||||
RicSnapshotAllPlotsToFileFeature::exportSnapshotOfAllPlotsIntoFolder(fullPathGeneratedFolder);
|
RicSnapshotAllPlotsToFileFeature::exportSnapshotOfAllPlotsIntoFolder(fullPathGeneratedFolder);
|
||||||
|
|
||||||
|
|||||||
@@ -141,7 +141,6 @@ public:
|
|||||||
void addWellPathsToModel(QList<QString> wellPathFilePaths);
|
void addWellPathsToModel(QList<QString> wellPathFilePaths);
|
||||||
void addWellLogsToModel(const QList<QString>& wellLogFilePaths);
|
void addWellLogsToModel(const QList<QString>& wellLogFilePaths);
|
||||||
|
|
||||||
void saveSnapshotForAllViews(const QString& snapshotFolderName);
|
|
||||||
void runMultiCaseSnapshots(const QString& templateProjectFileName, std::vector<QString> gridFileNames, const QString& snapshotFolderName);
|
void runMultiCaseSnapshots(const QString& templateProjectFileName, std::vector<QString> gridFileNames, const QString& snapshotFolderName);
|
||||||
void runRegressionTest(const QString& testRootPath);
|
void runRegressionTest(const QString& testRootPath);
|
||||||
|
|
||||||
@@ -206,12 +205,12 @@ public:
|
|||||||
|
|
||||||
static std::vector<QString> readFileListFromTextFile(QString listFileName);
|
static std::vector<QString> readFileListFromTextFile(QString listFileName);
|
||||||
|
|
||||||
|
void clearViewsScheduledForUpdate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void onProjectOpenedOrClosed();
|
void onProjectOpenedOrClosed();
|
||||||
void setWindowCaptionFromAppState();
|
void setWindowCaptionFromAppState();
|
||||||
|
|
||||||
void clearViewsScheduledForUpdate();
|
|
||||||
|
|
||||||
void createMainPlotWindow();
|
void createMainPlotWindow();
|
||||||
void deleteMainPlotWindow();
|
void deleteMainPlotWindow();
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "RicfCommandFileExecutor.h"
|
#include "RicfCommandFileExecutor.h"
|
||||||
|
|
||||||
#include "ExportCommands/RicSnapshotAllPlotsToFileFeature.h"
|
#include "ExportCommands/RicSnapshotAllPlotsToFileFeature.h"
|
||||||
|
#include "ExportCommands/RicSnapshotAllViewsToFileFeature.h"
|
||||||
|
|
||||||
#include "RiaApplication.h"
|
#include "RiaApplication.h"
|
||||||
|
|
||||||
@@ -65,7 +66,7 @@ void RicfExportSnapshots::execute()
|
|||||||
}
|
}
|
||||||
if (m_type == RicfExportSnapshots::VIEWS || m_type == RicfExportSnapshots::ALL)
|
if (m_type == RicfExportSnapshots::VIEWS || m_type == RicfExportSnapshots::ALL)
|
||||||
{
|
{
|
||||||
RiaApplication::instance()->saveSnapshotForAllViews(absolutePathToSnapshotDir);
|
RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(absolutePathToSnapshotDir);
|
||||||
}
|
}
|
||||||
if (m_type == RicfExportSnapshots::PLOTS || m_type == RicfExportSnapshots::ALL)
|
if (m_type == RicfExportSnapshots::PLOTS || m_type == RicfExportSnapshots::ALL)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ ${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputPropertyFeature.h
|
|||||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.h
|
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.h
|
||||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.h
|
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.h
|
||||||
${CEE_CURRENT_LIST_DIR}RicSnapshotAllPlotsToFileFeature.h
|
${CEE_CURRENT_LIST_DIR}RicSnapshotAllPlotsToFileFeature.h
|
||||||
|
${CEE_CURRENT_LIST_DIR}RicSnapshotAllViewsToFileFeature.h
|
||||||
|
${CEE_CURRENT_LIST_DIR}RicSnapshotFilenameGenerator.h
|
||||||
${CEE_CURRENT_LIST_DIR}RicSnapshotViewToClipboardFeature.h
|
${CEE_CURRENT_LIST_DIR}RicSnapshotViewToClipboardFeature.h
|
||||||
${CEE_CURRENT_LIST_DIR}RicSnapshotViewToFileFeature.h
|
${CEE_CURRENT_LIST_DIR}RicSnapshotViewToFileFeature.h
|
||||||
)
|
)
|
||||||
@@ -32,6 +34,8 @@ ${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputPropertyFeature.cpp
|
|||||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.cpp
|
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.cpp
|
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RicSnapshotAllPlotsToFileFeature.cpp
|
${CEE_CURRENT_LIST_DIR}RicSnapshotAllPlotsToFileFeature.cpp
|
||||||
|
${CEE_CURRENT_LIST_DIR}RicSnapshotAllViewsToFileFeature.cpp
|
||||||
|
${CEE_CURRENT_LIST_DIR}RicSnapshotFilenameGenerator.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RicSnapshotViewToClipboardFeature.cpp
|
${CEE_CURRENT_LIST_DIR}RicSnapshotViewToClipboardFeature.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RicSnapshotViewToFileFeature.cpp
|
${CEE_CURRENT_LIST_DIR}RicSnapshotViewToFileFeature.cpp
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include "RimViewWindow.h"
|
#include "RimViewWindow.h"
|
||||||
|
|
||||||
#include "RicSnapshotViewToFileFeature.h"
|
#include "RicSnapshotViewToFileFeature.h"
|
||||||
|
#include "RicSnapshotFilenameGenerator.h"
|
||||||
|
|
||||||
#include "RiuMainPlotWindow.h"
|
#include "RiuMainPlotWindow.h"
|
||||||
|
|
||||||
@@ -90,17 +91,7 @@ void RicSnapshotAllPlotsToFileFeature::exportSnapshotOfAllPlotsIntoFolder(QStrin
|
|||||||
{
|
{
|
||||||
if (viewWindow->isMdiWindow() && viewWindow->viewWidget())
|
if (viewWindow->isMdiWindow() && viewWindow->viewWidget())
|
||||||
{
|
{
|
||||||
QString fileName;
|
QString fileName = RicSnapshotFilenameGenerator::generateSnapshotFileName(viewWindow);
|
||||||
if ( viewWindow->userDescriptionField())
|
|
||||||
{
|
|
||||||
fileName = viewWindow->userDescriptionField()->uiCapability()->uiValue().toString();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fileName = viewWindow->uiCapability()->uiName();
|
|
||||||
}
|
|
||||||
|
|
||||||
fileName = caf::Utils::makeValidFileBasename(fileName);
|
|
||||||
|
|
||||||
QString absoluteFileName = caf::Utils::constructFullFileName(absSnapshotPath, fileName, ".png");
|
QString absoluteFileName = caf::Utils::constructFullFileName(absSnapshotPath, fileName, ".png");
|
||||||
absoluteFileName.replace(" ", "_");
|
absoluteFileName.replace(" ", "_");
|
||||||
|
|||||||
@@ -0,0 +1,167 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (C) 2016 Statoil ASA
|
||||||
|
//
|
||||||
|
// ResInsight is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "RicSnapshotAllViewsToFileFeature.h"
|
||||||
|
|
||||||
|
#include "RiaApplication.h"
|
||||||
|
#include "RiaLogging.h"
|
||||||
|
|
||||||
|
#include "RimMainPlotCollection.h"
|
||||||
|
#include "RimProject.h"
|
||||||
|
#include "RimViewWindow.h"
|
||||||
|
#include "RimView.h"
|
||||||
|
#include "RimCase.h"
|
||||||
|
|
||||||
|
#include "RicSnapshotViewToFileFeature.h"
|
||||||
|
#include "RicSnapshotFilenameGenerator.h"
|
||||||
|
|
||||||
|
#include "RiuMainWindow.h"
|
||||||
|
#include "RiuViewer.h"
|
||||||
|
|
||||||
|
#include "RigFemResultPosEnum.h"
|
||||||
|
|
||||||
|
#include "cafUtils.h"
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
|
#include <QClipboard>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QMdiSubWindow>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
|
||||||
|
CAF_CMD_SOURCE_INIT(RicSnapshotAllViewsToFileFeature, "RicSnapshotAllViewsToFileFeature");
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicSnapshotAllViewsToFileFeature::saveAllViews()
|
||||||
|
{
|
||||||
|
RiaApplication* app = RiaApplication::instance();
|
||||||
|
RimProject* proj = app->project();
|
||||||
|
if (!proj) return;
|
||||||
|
|
||||||
|
// Save images in snapshot catalog relative to project directory
|
||||||
|
QString snapshotFolderName = app->createAbsolutePathFromProjectRelativePath("snapshots");
|
||||||
|
|
||||||
|
exportSnapshotOfAllViewsIntoFolder(snapshotFolderName);
|
||||||
|
|
||||||
|
QString text = QString("Exported snapshots to folder : \n%1").arg(snapshotFolderName);
|
||||||
|
QMessageBox::information(nullptr, "Export Snapshots To Folder", text);
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(QString snapshotFolderName)
|
||||||
|
{
|
||||||
|
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
||||||
|
if (!mainWnd) return;
|
||||||
|
|
||||||
|
RimProject* project = RiaApplication::instance()->project();
|
||||||
|
|
||||||
|
if (project == nullptr) return;
|
||||||
|
|
||||||
|
QDir snapshotPath(snapshotFolderName);
|
||||||
|
if (!snapshotPath.exists())
|
||||||
|
{
|
||||||
|
if (!snapshotPath.mkpath(".")) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString absSnapshotPath = snapshotPath.absolutePath();
|
||||||
|
|
||||||
|
RiaLogging::info(QString("Exporting snapshot of all views to %1").arg(snapshotFolderName));
|
||||||
|
|
||||||
|
std::vector<RimCase*> projectCases;
|
||||||
|
project->allCases(projectCases);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < projectCases.size(); i++)
|
||||||
|
{
|
||||||
|
RimCase* cas = projectCases[i];
|
||||||
|
if (!cas) continue;
|
||||||
|
|
||||||
|
std::vector<RimView*> views = cas->views();
|
||||||
|
|
||||||
|
for (size_t j = 0; j < views.size(); j++)
|
||||||
|
{
|
||||||
|
RimView* riv = views[j];
|
||||||
|
|
||||||
|
if (riv && riv->viewer())
|
||||||
|
{
|
||||||
|
RiaApplication::instance()->setActiveReservoirView(riv);
|
||||||
|
|
||||||
|
RiuViewer* viewer = riv->viewer();
|
||||||
|
mainWnd->setActiveViewer(viewer->layoutWidget());
|
||||||
|
|
||||||
|
RiaApplication::instance()->clearViewsScheduledForUpdate();
|
||||||
|
|
||||||
|
//riv->updateCurrentTimeStepAndRedraw();
|
||||||
|
riv->createDisplayModelAndRedraw();
|
||||||
|
viewer->repaint();
|
||||||
|
|
||||||
|
QString fileName = RicSnapshotFilenameGenerator::generateSnapshotFileName(riv);
|
||||||
|
|
||||||
|
QString absoluteFileName = caf::Utils::constructFullFileName(absSnapshotPath, fileName, ".png");
|
||||||
|
|
||||||
|
RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, riv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RicSnapshotAllViewsToFileFeature::isCommandEnabled()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicSnapshotAllViewsToFileFeature::onActionTriggered(bool isChecked)
|
||||||
|
{
|
||||||
|
QWidget* currentActiveWidget = nullptr;
|
||||||
|
if (RiaApplication::activeViewWindow())
|
||||||
|
{
|
||||||
|
currentActiveWidget = RiaApplication::activeViewWindow()->viewWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
RicSnapshotAllViewsToFileFeature::saveAllViews();
|
||||||
|
|
||||||
|
if (currentActiveWidget)
|
||||||
|
{
|
||||||
|
RiuMainWindow* mainWindow = RiuMainWindow::instance();
|
||||||
|
if (mainWindow)
|
||||||
|
{
|
||||||
|
mainWindow->setActiveViewer(currentActiveWidget);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicSnapshotAllViewsToFileFeature::setupActionLook(QAction* actionToSetup)
|
||||||
|
{
|
||||||
|
actionToSetup->setText("Snapshot All Views To File");
|
||||||
|
actionToSetup->setIcon(QIcon(":/SnapShotSaveViews.png"));
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (C) 2016 Statoil ASA
|
||||||
|
//
|
||||||
|
// ResInsight is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "cafCmdFeature.h"
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
///
|
||||||
|
//==================================================================================================
|
||||||
|
class RicSnapshotAllViewsToFileFeature : public caf::CmdFeature
|
||||||
|
{
|
||||||
|
CAF_CMD_HEADER_INIT;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static void saveAllViews();
|
||||||
|
|
||||||
|
static void exportSnapshotOfAllViewsIntoFolder(QString snapshotFolderName);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Overrides
|
||||||
|
virtual bool isCommandEnabled() override;
|
||||||
|
virtual void onActionTriggered(bool isChecked) override;
|
||||||
|
virtual void setupActionLook(QAction* actionToSetup) override;
|
||||||
|
};
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (C) 2017 Statoil ASA
|
||||||
|
//
|
||||||
|
// ResInsight is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "RicSnapshotFilenameGenerator.h"
|
||||||
|
|
||||||
|
#include "RimViewWindow.h"
|
||||||
|
#include "RimView.h"
|
||||||
|
#include "RimCase.h"
|
||||||
|
#include "RimEclipseView.h"
|
||||||
|
#include "RimEclipseCellColors.h"
|
||||||
|
#include "RimGeoMechView.h"
|
||||||
|
#include "RimGeoMechCellColors.h"
|
||||||
|
|
||||||
|
#include "cafUtils.h"
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QString RicSnapshotFilenameGenerator::generateSnapshotFileName(RimViewWindow* viewWindow)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
RimView* view = dynamic_cast<RimView*>(viewWindow);
|
||||||
|
if (view != nullptr)
|
||||||
|
{
|
||||||
|
return generateSnapshotFilenameForRimView(view);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QString fileName;
|
||||||
|
if (viewWindow->userDescriptionField())
|
||||||
|
{
|
||||||
|
fileName = viewWindow->userDescriptionField()->uiCapability()->uiValue().toString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fileName = viewWindow->uiCapability()->uiName();
|
||||||
|
}
|
||||||
|
|
||||||
|
fileName = caf::Utils::makeValidFileBasename(fileName);
|
||||||
|
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QString RicSnapshotFilenameGenerator::generateSnapshotFilenameForRimView(RimView* rimView)
|
||||||
|
{
|
||||||
|
QStringList timeSteps = rimView->ownerCase()->timeStepStrings();
|
||||||
|
int timeStep = rimView->currentTimeStep();
|
||||||
|
|
||||||
|
QString fileName = QString("%1_%2_%3_%4_%5").arg(rimView->ownerCase()->caseUserDescription())
|
||||||
|
.arg(rimView->name())
|
||||||
|
.arg(resultName(rimView))
|
||||||
|
.arg(timeStep, 2, 10, QChar('0'))
|
||||||
|
.arg(timeSteps[timeStep].replace(".", "-"));
|
||||||
|
fileName = caf::Utils::makeValidFileBasename(fileName);
|
||||||
|
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QString RicSnapshotFilenameGenerator::resultName(RimView * rimView)
|
||||||
|
{
|
||||||
|
if (dynamic_cast<RimEclipseView*>(rimView))
|
||||||
|
{
|
||||||
|
RimEclipseView* eclView = dynamic_cast<RimEclipseView*>(rimView);
|
||||||
|
|
||||||
|
return caf::Utils::makeValidFileBasename(eclView->cellResult()->resultVariableUiShortName());
|
||||||
|
}
|
||||||
|
else if (dynamic_cast<RimGeoMechView*>(rimView))
|
||||||
|
{
|
||||||
|
RimGeoMechView* geoMechView = dynamic_cast<RimGeoMechView*>(rimView);
|
||||||
|
|
||||||
|
RimGeoMechCellColors* cellResult = geoMechView->cellResult();
|
||||||
|
|
||||||
|
if (cellResult)
|
||||||
|
{
|
||||||
|
QString title = QString("%1_%2").arg(caf::AppEnum<RigFemResultPosEnum>(cellResult->resultPositionType()).uiText())
|
||||||
|
.arg(cellResult->resultFieldUiName());
|
||||||
|
|
||||||
|
if (!cellResult->resultComponentUiName().isEmpty())
|
||||||
|
{
|
||||||
|
title += "_" + cellResult->resultComponentUiName();
|
||||||
|
}
|
||||||
|
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (C) 2017 Statoil ASA
|
||||||
|
//
|
||||||
|
// ResInsight is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
class RimViewWindow;
|
||||||
|
class RimView;
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
///
|
||||||
|
//==================================================================================================
|
||||||
|
class RicSnapshotFilenameGenerator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static QString generateSnapshotFileName(RimViewWindow* viewWindow);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static QString generateSnapshotFilenameForRimView(RimView* rimView);
|
||||||
|
static QString resultName(RimView* rimView);
|
||||||
|
};
|
||||||
@@ -26,6 +26,8 @@
|
|||||||
#include "RimViewWindow.h"
|
#include "RimViewWindow.h"
|
||||||
#include "RiuMainPlotWindow.h"
|
#include "RiuMainPlotWindow.h"
|
||||||
|
|
||||||
|
#include "RicSnapshotFilenameGenerator.h"
|
||||||
|
|
||||||
#include "cafUtils.h"
|
#include "cafUtils.h"
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
@@ -51,11 +53,11 @@ void RicSnapshotViewToFileFeature::saveSnapshotAs(const QString& fileName, RimVi
|
|||||||
{
|
{
|
||||||
if (image.save(fileName))
|
if (image.save(fileName))
|
||||||
{
|
{
|
||||||
qDebug() << "Exported snapshot image to " << fileName;
|
RiaLogging::info(QString("Exported snapshot image to %1").arg(fileName));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug() << "Error when trying to export snapshot image to " << fileName;
|
RiaLogging::error(QString("Error when trying to export snapshot image to %1").arg(fileName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -99,7 +101,7 @@ void RicSnapshotViewToFileFeature::onActionTriggered(bool isChecked)
|
|||||||
startPath = app->lastUsedDialogDirectory("IMAGE_SNAPSHOT");
|
startPath = app->lastUsedDialogDirectory("IMAGE_SNAPSHOT");
|
||||||
}
|
}
|
||||||
|
|
||||||
startPath += "/image.png";
|
startPath = caf::Utils::constructFullFileName(startPath, RicSnapshotFilenameGenerator::generateSnapshotFileName(viewWindow), ".png");
|
||||||
|
|
||||||
QString fileName = QFileDialog::getSaveFileName(NULL, tr("Export to File"), startPath);
|
QString fileName = QFileDialog::getSaveFileName(NULL, tr("Export to File"), startPath);
|
||||||
if (fileName.isEmpty())
|
if (fileName.isEmpty())
|
||||||
|
|||||||
@@ -58,6 +58,8 @@
|
|||||||
#include "cafSelectionManager.h"
|
#include "cafSelectionManager.h"
|
||||||
#include "cafUtils.h"
|
#include "cafUtils.h"
|
||||||
|
|
||||||
|
#include "ExportCommands/RicSnapshotAllViewsToFileFeature.h"
|
||||||
|
|
||||||
#include "cvfTimer.h"
|
#include "cvfTimer.h"
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
@@ -1271,7 +1273,7 @@ void RiuMainWindow::slotSnapshotAllViewsToFile()
|
|||||||
|
|
||||||
// Save images in snapshot catalog relative to project directory
|
// Save images in snapshot catalog relative to project directory
|
||||||
QString absolutePathToSnapshotDir = app->createAbsolutePathFromProjectRelativePath("snapshots");
|
QString absolutePathToSnapshotDir = app->createAbsolutePathFromProjectRelativePath("snapshots");
|
||||||
app->saveSnapshotForAllViews(absolutePathToSnapshotDir);
|
RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(absolutePathToSnapshotDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user