From 8a3907e53160b31921b8e12533159016e4123ec0 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 21 Nov 2018 10:26:46 +0100 Subject: [PATCH] #3725 exportSnapshots : Add optional prefix --- .../RicfExportSnapshots.cpp | 38 ++++++++++--------- .../RicfExportSnapshots.h | 11 +++--- .../RicSnapshotAllPlotsToFileFeature.cpp | 7 +++- .../RicSnapshotAllPlotsToFileFeature.h | 2 +- .../RicSnapshotAllViewsToFileFeature.cpp | 6 ++- .../RicSnapshotAllViewsToFileFeature.h | 2 +- 6 files changed, 39 insertions(+), 27 deletions(-) diff --git a/ApplicationCode/CommandFileInterface/RicfExportSnapshots.cpp b/ApplicationCode/CommandFileInterface/RicfExportSnapshots.cpp index 27c59aecd5..633bc85a49 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportSnapshots.cpp +++ b/ApplicationCode/CommandFileInterface/RicfExportSnapshots.cpp @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // 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 +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -31,27 +31,29 @@ CAF_PDM_SOURCE_INIT(RicfExportSnapshots, "exportSnapshots"); -namespace caf { - template<> - void RicfExportSnapshots::SnapshotsTypeEnum::setUp() - { - addItem(RicfExportSnapshots::ALL, "ALL", "All"); - addItem(RicfExportSnapshots::VIEWS, "VIEWS", "Views"); - addItem(RicfExportSnapshots::PLOTS, "PLOTS", "Plots"); - setDefault(RicfExportSnapshots::ALL); - } +namespace caf +{ +template<> +void RicfExportSnapshots::SnapshotsTypeEnum::setUp() +{ + addItem(RicfExportSnapshots::ALL, "ALL", "All"); + addItem(RicfExportSnapshots::VIEWS, "VIEWS", "Views"); + addItem(RicfExportSnapshots::PLOTS, "PLOTS", "Plots"); + setDefault(RicfExportSnapshots::ALL); } +} // namespace caf //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RicfExportSnapshots::RicfExportSnapshots() { - RICF_InitField(&m_type, "type", RicfExportSnapshots::SnapshotsTypeEnum(), "Type", "", "", ""); + RICF_InitField(&m_type, "type", RicfExportSnapshots::SnapshotsTypeEnum(), "Type", "", "", ""); + RICF_InitField(&m_prefix, "prefix", QString(), "Prefix", "", "", ""); } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicfExportSnapshots::execute() { @@ -67,11 +69,11 @@ void RicfExportSnapshots::execute() } if (m_type == RicfExportSnapshots::VIEWS || m_type == RicfExportSnapshots::ALL) { - RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(absolutePathToSnapshotDir); + RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(absolutePathToSnapshotDir, m_prefix); } if (m_type == RicfExportSnapshots::PLOTS || m_type == RicfExportSnapshots::ALL) { - RicSnapshotAllPlotsToFileFeature::exportSnapshotOfAllPlotsIntoFolder(absolutePathToSnapshotDir); + RicSnapshotAllPlotsToFileFeature::exportSnapshotOfAllPlotsIntoFolder(absolutePathToSnapshotDir, m_prefix); } mainWnd->loadWinGeoAndDockToolBarLayout(); diff --git a/ApplicationCode/CommandFileInterface/RicfExportSnapshots.h b/ApplicationCode/CommandFileInterface/RicfExportSnapshots.h index e2a6fe5e10..fcfac350f7 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportSnapshots.h +++ b/ApplicationCode/CommandFileInterface/RicfExportSnapshots.h @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // 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 +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -48,4 +48,5 @@ public: private: caf::PdmField m_type; -}; \ No newline at end of file + caf::PdmField m_prefix; +}; diff --git a/ApplicationCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.cpp index 3572a5c125..548cbaccde 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.cpp @@ -68,7 +68,7 @@ void RicSnapshotAllPlotsToFileFeature::saveAllPlots() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicSnapshotAllPlotsToFileFeature::exportSnapshotOfAllPlotsIntoFolder(QString snapshotFolderName) +void RicSnapshotAllPlotsToFileFeature::exportSnapshotOfAllPlotsIntoFolder(const QString& snapshotFolderName, const QString& prefix) { RiaApplication* app = RiaApplication::instance(); @@ -91,6 +91,11 @@ void RicSnapshotAllPlotsToFileFeature::exportSnapshotOfAllPlotsIntoFolder(QStrin if (viewWindow->isMdiWindow() && viewWindow->viewWidget()) { QString fileName = RicSnapshotFilenameGenerator::generateSnapshotFileName(viewWindow); + if (!prefix.isEmpty()) + { + fileName = prefix + fileName; + } + fileName.replace(" ", "_"); QString absoluteFileName = caf::Utils::constructFullFileName(absSnapshotPath, fileName, ".png"); diff --git a/ApplicationCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.h b/ApplicationCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.h index 45041d345d..f191172432 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.h +++ b/ApplicationCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.h @@ -32,7 +32,7 @@ class RicSnapshotAllPlotsToFileFeature : public caf::CmdFeature public: static void saveAllPlots(); - static void exportSnapshotOfAllPlotsIntoFolder(QString snapshotFolderName); + static void exportSnapshotOfAllPlotsIntoFolder(const QString& snapshotFolderName, const QString& prefix = ""); protected: // Overrides diff --git a/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp index 46f51c874e..2d880c5cef 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp @@ -70,7 +70,7 @@ void RicSnapshotAllViewsToFileFeature::saveAllViews() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(QString snapshotFolderName) +void RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(const QString& snapshotFolderName, const QString& prefix) { RimProject* project = RiaApplication::instance()->project(); @@ -114,6 +114,10 @@ void RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(QStrin viewer->repaint(); QString fileName = RicSnapshotFilenameGenerator::generateSnapshotFileName(riv); + if (!prefix.isEmpty()) + { + fileName = prefix + fileName; + } QString absoluteFileName = caf::Utils::constructFullFileName(absSnapshotPath, fileName, ".png"); diff --git a/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.h b/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.h index 82f333d96a..e8d664f36b 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.h +++ b/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.h @@ -32,7 +32,7 @@ class RicSnapshotAllViewsToFileFeature : public caf::CmdFeature public: static void saveAllViews(); - static void exportSnapshotOfAllViewsIntoFolder(QString snapshotFolderName); + static void exportSnapshotOfAllViewsIntoFolder(const QString& snapshotFolderName, const QString& prefix = ""); protected: // Overrides