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 "RiuPlotMainWindow.h"
#include "RicfMessages.h"
#include "RicfCommandFileExecutor.h"
#include "RicfMessages.h"
#include "ExportCommands/RicSnapshotViewToFileFeature.h"
#include "ExportCommands/RicSnapshotAllPlotsToFileFeature.h"
#include "ExportCommands/RicSnapshotAllViewsToFileFeature.h"
#include "ExportCommands/RicSnapshotViewToFileFeature.h"
#include "cvfProgramOptions.h"
#include "cvfqtUtils.h"
#include "cafUtils.h"
#include <QString>
#include <QStringList>
#include <QCoreApplication>
#include <QFile>
#include <QString>
#include <QStringList>
//--------------------------------------------------------------------------------------------------
///
@ -55,17 +55,49 @@ bool RiaArgumentParser::parseArguments()
cvf::ProgramOptions progOpt;
progOpt.registerOption("last", "", "Open last used project.");
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("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("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("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(
"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("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(
"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("?", "", "Displays help text.");
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
// This is based on a pull request by @andlaus https://github.com/OPM/ResInsight/pull/162
if (!parseOk ||
progOpt.hasOption("help") ||
progOpt.hasOption("?") ||
progOpt.positionalParameters().size() > 0)
if (!parseOk || progOpt.hasOption("help") || progOpt.hasOption("?") || progOpt.positionalParameters().size() > 0)
{
#if defined(_MSC_VER) && defined(_WIN32)
RiaApplication::instance()->showFormattedTextInMessageBox(helpText);
@ -103,7 +132,6 @@ bool RiaArgumentParser::parseArguments()
return false;
}
// Handling of the actual command line options
// --------------------------------------------------------
@ -145,7 +173,6 @@ bool RiaArgumentParser::parseArguments()
}
}
QString projectFileName;
if (progOpt.hasOption("last"))
@ -159,7 +186,6 @@ bool RiaArgumentParser::parseArguments()
projectFileName = cvfqt::Utils::toQString(o.value(0));
}
if (!projectFileName.isEmpty())
{
if (cvf::Option o = progOpt.option("multiCaseSnapshots"))
@ -172,7 +198,6 @@ bool RiaArgumentParser::parseArguments()
}
}
if (!projectFileName.isEmpty())
{
cvf::ref<RiaProjectModifier> projectModifier;
@ -213,7 +238,8 @@ bool RiaArgumentParser::parseArguments()
{
// 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);
}
else
@ -222,7 +248,8 @@ bool RiaArgumentParser::parseArguments()
while (optionIdx < o.valueCount())
{
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)
{
@ -262,38 +289,35 @@ bool RiaArgumentParser::parseArguments()
RiaApplication::instance()->loadProject(projectFileName, projectLoadAction, projectModifier.p());
}
if (cvf::Option o = progOpt.option("case"))
{
QStringList caseNames = cvfqt::Utils::toQStringList(o.values());
foreach (QString caseName, caseNames)
{
QString fileExtension = caf::Utils::fileExtension(caseName);
if (caf::Utils::fileExists(caseName) &&
(fileExtension == "EGRID" || fileExtension == "GRID"))
if (caf::Utils::fileExists(caseName) && (fileExtension == "EGRID" || fileExtension == "GRID"))
{
RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({ caseName }), nullptr, true);
RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({caseName}), nullptr, true);
}
else
{
QString caseFileNameWithExt = caseName + ".EGRID";
if (caf::Utils::fileExists(caseFileNameWithExt))
{
RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({ caseFileNameWithExt }), nullptr, true);
RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({caseFileNameWithExt}), nullptr, true);
}
else
{
caseFileNameWithExt = caseName + ".GRID";
if (caf::Utils::fileExists(caseFileNameWithExt))
{
RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({ caseFileNameWithExt }), nullptr, true);
RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({caseFileNameWithExt}), nullptr, true);
}
}
}
}
}
if (cvf::Option o = progOpt.option("savesnapshots"))
{
bool snapshotViews = false;
@ -333,7 +357,8 @@ bool RiaArgumentParser::parseArguments()
// 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()
QString absolutePathToSnapshotDir = RiaApplication::instance()->createAbsolutePathFromProjectRelativePath("snapshots");
QString absolutePathToSnapshotDir =
RiaApplication::instance()->createAbsolutePathFromProjectRelativePath("snapshots");
RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(absolutePathToSnapshotDir);
mainWnd->loadWinGeoAndDockToolBarLayout();
@ -406,7 +431,7 @@ bool RiaArgumentParser::parseArguments()
{
CVF_ASSERT(caseIds.size() == caseListFiles.size());
std::vector< std::vector<QString> > allCaseFiles;
std::vector<std::vector<QString>> allCaseFiles;
size_t maxFiles = 0;
for (size_t i = 0; i < caseIds.size(); ++i)