Whitespace

This commit is contained in:
Magne Sjaastad 2019-01-16 11:52:06 +01:00
parent 4e6add0c37
commit fd133b0d36

View File

@ -30,22 +30,22 @@
#include "RiuMainWindow.h" #include "RiuMainWindow.h"
#include "RiuPlotMainWindow.h" #include "RiuPlotMainWindow.h"
#include "RicfMessages.h"
#include "RicfCommandFileExecutor.h" #include "RicfCommandFileExecutor.h"
#include "RicfMessages.h"
#include "ExportCommands/RicSnapshotViewToFileFeature.h"
#include "ExportCommands/RicSnapshotAllPlotsToFileFeature.h" #include "ExportCommands/RicSnapshotAllPlotsToFileFeature.h"
#include "ExportCommands/RicSnapshotAllViewsToFileFeature.h" #include "ExportCommands/RicSnapshotAllViewsToFileFeature.h"
#include "ExportCommands/RicSnapshotViewToFileFeature.h"
#include "cvfProgramOptions.h" #include "cvfProgramOptions.h"
#include "cvfqtUtils.h" #include "cvfqtUtils.h"
#include "cafUtils.h" #include "cafUtils.h"
#include <QString>
#include <QStringList>
#include <QCoreApplication> #include <QCoreApplication>
#include <QFile> #include <QFile>
#include <QString>
#include <QStringList>
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
@ -55,17 +55,49 @@ bool RiaArgumentParser::parseArguments()
cvf::ProgramOptions progOpt; cvf::ProgramOptions progOpt;
progOpt.registerOption("last", "", "Open last used project."); progOpt.registerOption("last", "", "Open last used project.");
progOpt.registerOption("project", "<filename>", "Open project file <filename>.", cvf::ProgramOptions::SINGLE_VALUE); progOpt.registerOption("project", "<filename>", "Open project file <filename>.", cvf::ProgramOptions::SINGLE_VALUE);
progOpt.registerOption("case", "<casename>", "Import Eclipse case <casename> (do not include the .GRID/.EGRID extension.)", cvf::ProgramOptions::MULTI_VALUE); progOpt.registerOption("case",
"<casename>",
"Import Eclipse case <casename> (do not include the .GRID/.EGRID extension.)",
cvf::ProgramOptions::MULTI_VALUE);
progOpt.registerOption("startdir", "<folder>", "Set startup directory.", cvf::ProgramOptions::SINGLE_VALUE); progOpt.registerOption("startdir", "<folder>", "Set startup directory.", cvf::ProgramOptions::SINGLE_VALUE);
progOpt.registerOption("savesnapshots", "all|views|plots", "Save snapshot of all views or plots to project file location sub folder 'snapshots'. Option 'all' will include both views and plots. Application closes after snapshots have been written.", cvf::ProgramOptions::OPTIONAL_MULTI_VALUE); progOpt.registerOption("savesnapshots",
progOpt.registerOption("size", "<width> <height>", "Set size of the main application window.", cvf::ProgramOptions::MULTI_VALUE); "all|views|plots",
progOpt.registerOption("replaceCase", "[<caseId>] <newGridFile>", "Replace grid in <caseId> or first case with <newgridFile>. Repeat parameter for multiple replace operations.", cvf::ProgramOptions::MULTI_VALUE, cvf::ProgramOptions::COMBINE_REPEATED); "Save snapshot of all views or plots to project file location sub folder 'snapshots'. Option 'all' "
progOpt.registerOption("replaceSourceCases", "[<caseGroupId>] <gridListFile>", "Replace source cases in <caseGroupId> or first grid case group with the grid files listed in the <gridListFile> file. Repeat parameter for multiple replace operations.", cvf::ProgramOptions::MULTI_VALUE, cvf::ProgramOptions::COMBINE_REPEATED); "will include both views and plots. Application closes after snapshots have been written.",
progOpt.registerOption("replacePropertiesFolder", "[<caseId>] <newPropertiesFolder>", "Replace the folder containing property files for an eclipse input case.", cvf::ProgramOptions::MULTI_VALUE); cvf::ProgramOptions::OPTIONAL_MULTI_VALUE);
progOpt.registerOption("multiCaseSnapshots", "<gridListFile>", "For each grid file listed in the <gridListFile> file, replace the first case in the project and save snapshot of all views.", cvf::ProgramOptions::SINGLE_VALUE); progOpt.registerOption(
"size", "<width> <height>", "Set size of the main application window.", cvf::ProgramOptions::MULTI_VALUE);
progOpt.registerOption(
"replaceCase",
"[<caseId>] <newGridFile>",
"Replace grid in <caseId> or first case with <newgridFile>. Repeat parameter for multiple replace operations.",
cvf::ProgramOptions::MULTI_VALUE,
cvf::ProgramOptions::COMBINE_REPEATED);
progOpt.registerOption("replaceSourceCases",
"[<caseGroupId>] <gridListFile>",
"Replace source cases in <caseGroupId> or first grid case group with the grid files listed in the "
"<gridListFile> file. Repeat parameter for multiple replace operations.",
cvf::ProgramOptions::MULTI_VALUE,
cvf::ProgramOptions::COMBINE_REPEATED);
progOpt.registerOption("replacePropertiesFolder",
"[<caseId>] <newPropertiesFolder>",
"Replace the folder containing property files for an eclipse input case.",
cvf::ProgramOptions::MULTI_VALUE);
progOpt.registerOption("multiCaseSnapshots",
"<gridListFile>",
"For each grid file listed in the <gridListFile> file, replace the first case in the project and save "
"snapshot of all views.",
cvf::ProgramOptions::SINGLE_VALUE);
progOpt.registerOption("commandFile", "<commandfile>", "Execute the command file.", cvf::ProgramOptions::SINGLE_VALUE); progOpt.registerOption("commandFile", "<commandfile>", "Execute the command file.", cvf::ProgramOptions::SINGLE_VALUE);
progOpt.registerOption("commandFileProject", "<filename>", "Project to use if performing case looping for command file. Used in conjunction with 'commandFileReplaceCases'.", cvf::ProgramOptions::SINGLE_VALUE); progOpt.registerOption(
progOpt.registerOption("commandFileReplaceCases", "[<caseId>] <caseListFile>", "Supply list of cases to replace in project, performing command file for each case.", cvf::ProgramOptions::SINGLE_VALUE); "commandFileProject",
"<filename>",
"Project to use if performing case looping for command file. Used in conjunction with 'commandFileReplaceCases'.",
cvf::ProgramOptions::SINGLE_VALUE);
progOpt.registerOption("commandFileReplaceCases",
"[<caseId>] <caseListFile>",
"Supply list of cases to replace in project, performing command file for each case.",
cvf::ProgramOptions::SINGLE_VALUE);
progOpt.registerOption("help", "", "Displays help text."); progOpt.registerOption("help", "", "Displays help text.");
progOpt.registerOption("?", "", "Displays help text."); progOpt.registerOption("?", "", "Displays help text.");
progOpt.registerOption("regressiontest", "<folder>", "System command", cvf::ProgramOptions::SINGLE_VALUE); progOpt.registerOption("regressiontest", "<folder>", "System command", cvf::ProgramOptions::SINGLE_VALUE);
@ -89,10 +121,7 @@ bool RiaArgumentParser::parseArguments()
// If positional parameter functionality is to be supported, the test for existence of positionalParameters must be removed // If positional parameter functionality is to be supported, the test for existence of positionalParameters must be removed
// This is based on a pull request by @andlaus https://github.com/OPM/ResInsight/pull/162 // This is based on a pull request by @andlaus https://github.com/OPM/ResInsight/pull/162
if (!parseOk || if (!parseOk || progOpt.hasOption("help") || progOpt.hasOption("?") || progOpt.positionalParameters().size() > 0)
progOpt.hasOption("help") ||
progOpt.hasOption("?") ||
progOpt.positionalParameters().size() > 0)
{ {
#if defined(_MSC_VER) && defined(_WIN32) #if defined(_MSC_VER) && defined(_WIN32)
RiaApplication::instance()->showFormattedTextInMessageBox(helpText); RiaApplication::instance()->showFormattedTextInMessageBox(helpText);
@ -103,7 +132,6 @@ bool RiaArgumentParser::parseArguments()
return false; return false;
} }
// Handling of the actual command line options // Handling of the actual command line options
// -------------------------------------------------------- // --------------------------------------------------------
@ -145,7 +173,6 @@ bool RiaArgumentParser::parseArguments()
} }
} }
QString projectFileName; QString projectFileName;
if (progOpt.hasOption("last")) if (progOpt.hasOption("last"))
@ -159,7 +186,6 @@ bool RiaArgumentParser::parseArguments()
projectFileName = cvfqt::Utils::toQString(o.value(0)); projectFileName = cvfqt::Utils::toQString(o.value(0));
} }
if (!projectFileName.isEmpty()) if (!projectFileName.isEmpty())
{ {
if (cvf::Option o = progOpt.option("multiCaseSnapshots")) if (cvf::Option o = progOpt.option("multiCaseSnapshots"))
@ -172,7 +198,6 @@ bool RiaArgumentParser::parseArguments()
} }
} }
if (!projectFileName.isEmpty()) if (!projectFileName.isEmpty())
{ {
cvf::ref<RiaProjectModifier> projectModifier; cvf::ref<RiaProjectModifier> projectModifier;
@ -213,7 +238,8 @@ bool RiaArgumentParser::parseArguments()
{ {
// One argument is available, use replace case for first occurrence in the project // One argument is available, use replace case for first occurrence in the project
std::vector<QString> gridFileNames = RiaApplication::readFileListFromTextFile(cvfqt::Utils::toQString(o.safeValue(0))); std::vector<QString> gridFileNames =
RiaApplication::readFileListFromTextFile(cvfqt::Utils::toQString(o.safeValue(0)));
projectModifier->setReplaceSourceCasesFirstOccurrence(gridFileNames); projectModifier->setReplaceSourceCasesFirstOccurrence(gridFileNames);
} }
else else
@ -222,7 +248,8 @@ bool RiaArgumentParser::parseArguments()
while (optionIdx < o.valueCount()) while (optionIdx < o.valueCount())
{ {
const int groupId = o.safeValue(optionIdx++).toInt(-1); const int groupId = o.safeValue(optionIdx++).toInt(-1);
std::vector<QString> gridFileNames = RiaApplication::readFileListFromTextFile(cvfqt::Utils::toQString(o.safeValue(optionIdx++))); std::vector<QString> gridFileNames =
RiaApplication::readFileListFromTextFile(cvfqt::Utils::toQString(o.safeValue(optionIdx++)));
if (groupId != -1 && gridFileNames.size() > 0) if (groupId != -1 && gridFileNames.size() > 0)
{ {
@ -262,38 +289,35 @@ bool RiaArgumentParser::parseArguments()
RiaApplication::instance()->loadProject(projectFileName, projectLoadAction, projectModifier.p()); RiaApplication::instance()->loadProject(projectFileName, projectLoadAction, projectModifier.p());
} }
if (cvf::Option o = progOpt.option("case")) if (cvf::Option o = progOpt.option("case"))
{ {
QStringList caseNames = cvfqt::Utils::toQStringList(o.values()); QStringList caseNames = cvfqt::Utils::toQStringList(o.values());
foreach (QString caseName, caseNames) foreach (QString caseName, caseNames)
{ {
QString fileExtension = caf::Utils::fileExtension(caseName); QString fileExtension = caf::Utils::fileExtension(caseName);
if (caf::Utils::fileExists(caseName) && if (caf::Utils::fileExists(caseName) && (fileExtension == "EGRID" || fileExtension == "GRID"))
(fileExtension == "EGRID" || fileExtension == "GRID"))
{ {
RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({ caseName }), nullptr, true); RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({caseName}), nullptr, true);
} }
else else
{ {
QString caseFileNameWithExt = caseName + ".EGRID"; QString caseFileNameWithExt = caseName + ".EGRID";
if (caf::Utils::fileExists(caseFileNameWithExt)) if (caf::Utils::fileExists(caseFileNameWithExt))
{ {
RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({ caseFileNameWithExt }), nullptr, true); RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({caseFileNameWithExt}), nullptr, true);
} }
else else
{ {
caseFileNameWithExt = caseName + ".GRID"; caseFileNameWithExt = caseName + ".GRID";
if (caf::Utils::fileExists(caseFileNameWithExt)) if (caf::Utils::fileExists(caseFileNameWithExt))
{ {
RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({ caseFileNameWithExt }), nullptr, true); RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({caseFileNameWithExt}), nullptr, true);
} }
} }
} }
} }
} }
if (cvf::Option o = progOpt.option("savesnapshots")) if (cvf::Option o = progOpt.option("savesnapshots"))
{ {
bool snapshotViews = false; bool snapshotViews = false;
@ -333,7 +357,8 @@ bool RiaArgumentParser::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 = RiaApplication::instance()->createAbsolutePathFromProjectRelativePath("snapshots"); QString absolutePathToSnapshotDir =
RiaApplication::instance()->createAbsolutePathFromProjectRelativePath("snapshots");
RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(absolutePathToSnapshotDir); RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(absolutePathToSnapshotDir);
mainWnd->loadWinGeoAndDockToolBarLayout(); mainWnd->loadWinGeoAndDockToolBarLayout();
@ -406,7 +431,7 @@ bool RiaArgumentParser::parseArguments()
{ {
CVF_ASSERT(caseIds.size() == caseListFiles.size()); CVF_ASSERT(caseIds.size() == caseListFiles.size());
std::vector< std::vector<QString> > allCaseFiles; std::vector<std::vector<QString>> allCaseFiles;
size_t maxFiles = 0; size_t maxFiles = 0;
for (size_t i = 0; i < caseIds.size(); ++i) for (size_t i = 0; i < caseIds.size(); ++i)