Merge branch 'dev' into pre-proto

This commit is contained in:
Bjørnar Grip Fjær
2017-08-01 12:44:11 +02:00
128 changed files with 5129 additions and 423 deletions

View File

@@ -90,9 +90,11 @@
#include "RiuFlowCharacteristicsPlot.h"
#include "RicImportSummaryCaseFeature.h"
#include "RicSnapshotViewToClipboardFeature.h"
#include "ExportCommands/RicSnapshotViewToClipboardFeature.h"
#include "SummaryPlotCommands/RicNewSummaryPlotFeature.h"
#include "RicfCommandFileExecutor.h"
#include "cafFixedAtlasFont.h"
#include "cafAppEnum.h"
@@ -218,6 +220,8 @@ RiaApplication::RiaApplication(int& argc, char** argv)
m_runningRegressionTests = false;
m_runningWorkerProcess = false;
m_mainPlotWindow = nullptr;
m_recentFileActionProvider = std::unique_ptr<RiuRecentFileActionProvider>(new RiuRecentFileActionProvider);
@@ -1320,7 +1324,9 @@ bool RiaApplication::parseArguments()
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("help", "", "Displays help text.");
progOpt.registerOption("?", "", "Displays help text.");
progOpt.registerOption("regressiontest", "<folder>", "System command", cvf::ProgramOptions::SINGLE_VALUE);
@@ -1483,6 +1489,30 @@ bool RiaApplication::parseArguments()
projectLoadAction = PLA_CALCULATE_STATISTICS;
}
if (cvf::Option o = progOpt.option("replacePropertiesFolder"))
{
if (projectModifier.isNull()) projectModifier = new RiaProjectModifier;
if (o.valueCount() == 1)
{
QString propertiesFolder = cvfqt::Utils::toQString(o.safeValue(0));
projectModifier->setReplacePropertiesFolderFirstOccurrence(propertiesFolder);
}
else
{
size_t optionIdx = 0;
while (optionIdx < o.valueCount())
{
const int caseId = o.safeValue(optionIdx++).toInt(-1);
QString propertiesFolder = cvfqt::Utils::toQString(o.safeValue(optionIdx++));
if (caseId != -1 && !propertiesFolder.isEmpty())
{
projectModifier->setReplacePropertiesFolder(caseId, propertiesFolder);
}
}
}
}
loadProject(projectFileName, projectLoadAction, projectModifier.p());
}
@@ -1493,18 +1523,27 @@ bool RiaApplication::parseArguments()
QStringList caseNames = cvfqt::Utils::toQStringList(o.values());
foreach (QString caseName, caseNames)
{
QString caseFileNameWithExt = caseName + ".EGRID";
if (caf::Utils::fileExists(caseFileNameWithExt))
QString fileExtension = caf::Utils::fileExtension(caseName);
if (caf::Utils::fileExists(caseName) &&
(fileExtension == "EGRID" || fileExtension == "GRID"))
{
openEclipseCaseFromFile(caseFileNameWithExt);
openEclipseCaseFromFile(caseName);
}
else
{
caseFileNameWithExt = caseName + ".GRID";
QString caseFileNameWithExt = caseName + ".EGRID";
if (caf::Utils::fileExists(caseFileNameWithExt))
{
openEclipseCaseFromFile(caseFileNameWithExt);
}
else
{
caseFileNameWithExt = caseName + ".GRID";
if (caf::Utils::fileExists(caseFileNameWithExt))
{
openEclipseCaseFromFile(caseFileNameWithExt);
}
}
}
}
}
@@ -1576,6 +1615,24 @@ bool RiaApplication::parseArguments()
return false;
}
if (cvf::Option o = progOpt.option("commandFile"))
{
QString commandFile = cvfqt::Utils::toQString(o.safeValue(0));
QFile file(commandFile);
RicfMessages messages;
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
// TODO : Error logging?
return false;
}
QTextStream in(&file);
RicfCommandFileExecutor::instance()->executeCommands(in);
closeAllWindows();
processEvents();
return false;
}
return true;
}
@@ -1795,6 +1852,14 @@ std::vector<QAction*> RiaApplication::recentFileActions() const
return m_recentFileActionProvider->actions();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication::setStartDir(const QString& startDir)
{
m_startupDefaultDirectory = startDir;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -1895,6 +1960,7 @@ void RiaApplication::slotWorkerProcessFinished(int exitCode, QProcess::ExitStatu
if (exitStatus == QProcess::CrashExit)
{
// MFLog::error("Simulation execution crashed or was aborted.");
m_runningWorkerProcess = false;
return;
}
@@ -1906,6 +1972,7 @@ void RiaApplication::slotWorkerProcessFinished(int exitCode, QProcess::ExitStatu
if (exitCode != 0)
{
// MFLog::error(QString("Simulation execution failed (exit code %1).").arg(exitCode));
m_runningWorkerProcess = false;
return;
}
@@ -1918,6 +1985,7 @@ void RiaApplication::slotWorkerProcessFinished(int exitCode, QProcess::ExitStatu
{
// Disable concept of current case
m_socketServer->setCurrentCaseId(-1);
m_runningWorkerProcess = false;
}
}
@@ -1942,6 +2010,7 @@ bool RiaApplication::launchProcess(const QString& program, const QStringList& ar
m_socketServer->setCurrentCaseId(-1);
}
m_runningWorkerProcess = true;
m_workerProcess = new caf::UiProcess(this);
QProcessEnvironment penv = QProcessEnvironment::systemEnvironment();
@@ -1978,6 +2047,7 @@ bool RiaApplication::launchProcess(const QString& program, const QStringList& ar
{
m_workerProcess->close();
m_workerProcess = NULL;
m_runningWorkerProcess = false;
RiuMainWindow::instance()->processMonitor()->stopMonitorWorkProcess();
@@ -2097,9 +2167,25 @@ void RiaApplication::terminateProcess()
m_workerProcess->close();
}
m_runningWorkerProcess = false;
m_workerProcess = NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication::waitForProcess() const
{
while (m_runningWorkerProcess)
{
#ifdef WIN32
Sleep(100);
#else
usleep(100000);
#endif
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -82,6 +82,12 @@ public:
NAVIGATION_POLICY_RMS
};
enum ProjectLoadAction
{
PLA_NONE = 0,
PLA_CALCULATE_STATISTICS = 1
};
public:
RiaApplication(int& argc, char** argv);
~RiaApplication();
@@ -125,6 +131,7 @@ public:
QString currentProjectPath() const;
QString createAbsolutePathFromProjectRelativePath(QString projectRelativePath);
bool loadProject(const QString& projectFileName);
bool loadProject(const QString& projectFileName, ProjectLoadAction loadAction, RiaProjectModifier* projectModifier);
bool saveProject();
bool saveProjectAs(const QString& fileName);
bool saveProjectPromptForFileName();
@@ -160,6 +167,7 @@ public:
bool launchProcess(const QString& program, const QStringList& arguments);
bool launchProcessForMultipleCases(const QString& program, const QStringList& arguments, const std::vector<int>& caseIds);
void terminateProcess();
void waitForProcess() const;
RiaPreferences* preferences();
void applyPreferences();
@@ -196,17 +204,13 @@ public:
void addToRecentFiles(const QString& fileName);
std::vector<QAction*> recentFileActions() const;
private:
enum ProjectLoadAction
{
PLA_NONE = 0,
PLA_CALCULATE_STATISTICS = 1
};
void setStartDir(const QString& startDir);
bool loadProject(const QString& projectFileName, ProjectLoadAction loadAction, RiaProjectModifier* projectModifier);
static std::vector<QString> readFileListFromTextFile(QString listFileName);
private:
void onProjectOpenedOrClosed();
std::vector<QString> readFileListFromTextFile(QString listFileName);
void setWindowCaptionFromAppState();
void clearViewsScheduledForUpdate();
@@ -269,6 +273,8 @@ private:
QString m_helpText;
bool m_runningRegressionTests;
bool m_runningWorkerProcess;
RiuMainPlotWindow* m_mainPlotWindow;
std::unique_ptr<RiuRecentFileActionProvider> m_recentFileActionProvider;

View File

@@ -44,11 +44,11 @@ int main(int argc, char *argv[])
window.loadWinGeoAndDockToolBarLayout();
window.showWindow();
RiaLogging::setLoggerInstance(new RiuMessagePanelLogger(window.messagePanel()));
RiaLogging::loggerInstance()->setLevel(RI_LL_DEBUG);
if (app.parseArguments())
{
RiaLogging::setLoggerInstance(new RiuMessagePanelLogger(window.messagePanel()));
RiaLogging::loggerInstance()->setLevel(RI_LL_DEBUG);
int exitCode = app.exec();
RiaLogging::deleteLoggerInstance();

View File

@@ -21,6 +21,7 @@
#include "RimCaseCollection.h"
#include "RimEclipseCaseCollection.h"
#include "RimEclipseInputCase.h"
#include "RimEclipseResultCase.h"
#include "RimIdenticalGridCaseGroup.h"
#include "RimOilField.h"
@@ -75,6 +76,25 @@ void RiaProjectModifier::setReplaceSourceCasesById(int caseGroupIdToReplace, std
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaProjectModifier::setReplacePropertiesFolderFirstOccurrence(QString newPropertiesFolder)
{
m_caseIdToPropertiesFolderMap[RiaProjectModifier::firstOccurrenceId()] = makeFilePathAbsolute(newPropertiesFolder);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaProjectModifier::setReplacePropertiesFolder(int caseIdToReplace, QString newPropertiesFolder)
{
if (caseIdToReplace >= 0)
{
m_caseIdToPropertiesFolderMap[caseIdToReplace] = makeFilePathAbsolute(newPropertiesFolder);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -90,6 +110,11 @@ bool RiaProjectModifier::applyModificationsToProject(RimProject* project)
replaceSourceCases(project);
}
if (m_caseIdToPropertiesFolderMap.size() > 0)
{
replacePropertiesFolder(project);
}
return true;
}
@@ -167,6 +192,38 @@ void RiaProjectModifier::replaceCase(RimProject* project)
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaProjectModifier::replacePropertiesFolder(RimProject* project)
{
std::vector<RimCase*> allCases;
project->allCases(allCases);
for (RimCase* rimCase : allCases)
{
RimEclipseInputCase* inputCase = dynamic_cast<RimEclipseInputCase*>(rimCase);
if (inputCase)
{
for (auto item : m_caseIdToPropertiesFolderMap)
{
int caseIdToReplace = item.first;
if (caseIdToReplace == RiaProjectModifier::firstOccurrenceId())
{
caseIdToReplace = firstInputCaseId(project);
}
if (caseIdToReplace == inputCase->caseId())
{
inputCase->updateAdditionalFileFolder(item.second);
}
}
}
}
}
//--------------------------------------------------------------------------------------------------
/// Returns absolute path name to the specified file.
///
@@ -236,6 +293,26 @@ int RiaProjectModifier::firstGroupId(RimProject* project)
return -1;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RiaProjectModifier::firstInputCaseId(RimProject * project)
{
std::vector<RimCase*> allCases;
project->allCases(allCases);
for (RimCase* rimCase : allCases)
{
RimEclipseInputCase* resultCase = dynamic_cast<RimEclipseInputCase*>(rimCase);
if (resultCase)
{
return resultCase->caseId();
}
}
return -1;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -47,21 +47,28 @@ public:
void setReplaceSourceCasesFirstOccurrence(std::vector<QString> newGridFileNames);
void setReplaceSourceCasesById(int caseGroupIdToReplace, std::vector<QString> newGridFileNames);
void setReplacePropertiesFolderFirstOccurrence(QString newPropertiesFolder);
void setReplacePropertiesFolder(int caseIdToReplace, QString newPropertiesFolder);
bool applyModificationsToProject(RimProject* project);
private:
void replaceSourceCases(RimProject* project);
void replaceCase(RimProject* project);
void replacePropertiesFolder(RimProject* project);
static QString makeFilePathAbsolute(QString relOrAbsolutePath);
static QString caseNameFromGridFileName(QString fullGridFilePathName);
static int firstCaseId(RimProject* project);
static int firstGroupId(RimProject* project);
static int firstInputCaseId(RimProject* project);
static int firstOccurrenceId();
private:
std::map<int, QString> m_caseIdToGridFileNameMap;
std::map<int, std::vector<QString> > m_groupIdToGridFileNamesMap;
std::map<int, QString> m_caseIdToPropertiesFolderMap;
};