mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1665 Add replaceCase command to command file interface
This commit is contained in:
@@ -82,6 +82,12 @@ public:
|
|||||||
NAVIGATION_POLICY_RMS
|
NAVIGATION_POLICY_RMS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ProjectLoadAction
|
||||||
|
{
|
||||||
|
PLA_NONE = 0,
|
||||||
|
PLA_CALCULATE_STATISTICS = 1
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RiaApplication(int& argc, char** argv);
|
RiaApplication(int& argc, char** argv);
|
||||||
~RiaApplication();
|
~RiaApplication();
|
||||||
@@ -123,6 +129,7 @@ public:
|
|||||||
QString currentProjectPath() const;
|
QString currentProjectPath() const;
|
||||||
QString createAbsolutePathFromProjectRelativePath(QString projectRelativePath);
|
QString createAbsolutePathFromProjectRelativePath(QString projectRelativePath);
|
||||||
bool loadProject(const QString& projectFileName);
|
bool loadProject(const QString& projectFileName);
|
||||||
|
bool loadProject(const QString& projectFileName, ProjectLoadAction loadAction, RiaProjectModifier* projectModifier);
|
||||||
bool saveProject();
|
bool saveProject();
|
||||||
bool saveProjectAs(const QString& fileName);
|
bool saveProjectAs(const QString& fileName);
|
||||||
bool saveProjectPromptForFileName();
|
bool saveProjectPromptForFileName();
|
||||||
@@ -196,17 +203,11 @@ public:
|
|||||||
|
|
||||||
void setStartDir(const QString& startDir);
|
void setStartDir(const QString& startDir);
|
||||||
|
|
||||||
private:
|
static std::vector<QString> readFileListFromTextFile(QString listFileName);
|
||||||
enum ProjectLoadAction
|
|
||||||
{
|
|
||||||
PLA_NONE = 0,
|
|
||||||
PLA_CALCULATE_STATISTICS = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
bool loadProject(const QString& projectFileName, ProjectLoadAction loadAction, RiaProjectModifier* projectModifier);
|
private:
|
||||||
|
|
||||||
void onProjectOpenedOrClosed();
|
void onProjectOpenedOrClosed();
|
||||||
std::vector<QString> readFileListFromTextFile(QString listFileName);
|
|
||||||
void setWindowCaptionFromAppState();
|
void setWindowCaptionFromAppState();
|
||||||
|
|
||||||
void clearViewsScheduledForUpdate();
|
void clearViewsScheduledForUpdate();
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicfExportSnapshots.h
|
|||||||
${CMAKE_CURRENT_LIST_DIR}/RicfExportWellPathCompletions.h
|
${CMAKE_CURRENT_LIST_DIR}/RicfExportWellPathCompletions.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicfLoadCase.h
|
${CMAKE_CURRENT_LIST_DIR}/RicfLoadCase.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicfOpenProject.h
|
${CMAKE_CURRENT_LIST_DIR}/RicfOpenProject.h
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RicfReplaceCase.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicfRunOctaveScript.h
|
${CMAKE_CURRENT_LIST_DIR}/RicfRunOctaveScript.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicfSetExportFolder.h
|
${CMAKE_CURRENT_LIST_DIR}/RicfSetExportFolder.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicfSetMainWindowSize.h
|
${CMAKE_CURRENT_LIST_DIR}/RicfSetMainWindowSize.h
|
||||||
@@ -26,6 +27,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicfExportSnapshots.cpp
|
|||||||
${CMAKE_CURRENT_LIST_DIR}/RicfExportWellPathCompletions.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RicfExportWellPathCompletions.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicfLoadCase.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RicfLoadCase.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicfOpenProject.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RicfOpenProject.cpp
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RicfReplaceCase.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicfRunOctaveScript.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RicfRunOctaveScript.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicfSetExportFolder.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RicfSetExportFolder.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicfSetMainWindowSize.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RicfSetMainWindowSize.cpp
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ void RicfCommandFileExecutor::setExportPath(ExportType type, QString path)
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
QString RicfCommandFileExecutor::getExportPath(ExportType type)
|
QString RicfCommandFileExecutor::getExportPath(ExportType type) const
|
||||||
{
|
{
|
||||||
auto it = m_exportPaths.find(type);
|
auto it = m_exportPaths.find(type);
|
||||||
QString path;
|
QString path;
|
||||||
@@ -95,6 +95,22 @@ QString RicfCommandFileExecutor::getExportPath(ExportType type)
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicfCommandFileExecutor::setLastProjectPath(const QString& path)
|
||||||
|
{
|
||||||
|
m_lastProjectPath = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QString RicfCommandFileExecutor::getLastProjectPath() const
|
||||||
|
{
|
||||||
|
return m_lastProjectPath;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -39,7 +39,9 @@ public:
|
|||||||
|
|
||||||
void executeCommands(QTextStream& stream);
|
void executeCommands(QTextStream& stream);
|
||||||
void setExportPath(ExportType type, QString path);
|
void setExportPath(ExportType type, QString path);
|
||||||
QString getExportPath(ExportType type);
|
QString getExportPath(ExportType type) const;
|
||||||
|
void setLastProjectPath(const QString& path);
|
||||||
|
QString getLastProjectPath() const;
|
||||||
|
|
||||||
static RicfCommandFileExecutor* instance();
|
static RicfCommandFileExecutor* instance();
|
||||||
|
|
||||||
@@ -47,4 +49,5 @@ private:
|
|||||||
RicfMessages m_messages;
|
RicfMessages m_messages;
|
||||||
|
|
||||||
std::map<ExportType, QString> m_exportPaths;
|
std::map<ExportType, QString> m_exportPaths;
|
||||||
|
QString m_lastProjectPath;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
#include "RicfOpenProject.h"
|
#include "RicfOpenProject.h"
|
||||||
|
|
||||||
|
#include "RicfCommandFileExecutor.h"
|
||||||
|
|
||||||
#include "RiaApplication.h"
|
#include "RiaApplication.h"
|
||||||
#include "RiaLogging.h"
|
#include "RiaLogging.h"
|
||||||
|
|
||||||
@@ -40,5 +42,8 @@ void RicfOpenProject::execute()
|
|||||||
if (!ok)
|
if (!ok)
|
||||||
{
|
{
|
||||||
RiaLogging::error(QString("openProject: Unable to open project at %1").arg(m_path()));
|
RiaLogging::error(QString("openProject: Unable to open project at %1").arg(m_path()));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RicfCommandFileExecutor::instance()->setLastProjectPath(m_path);
|
||||||
}
|
}
|
||||||
|
|||||||
68
ApplicationCode/CommandFileInterface/RicfReplaceCase.cpp
Normal file
68
ApplicationCode/CommandFileInterface/RicfReplaceCase.cpp
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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 "RicfReplaceCase.h"
|
||||||
|
|
||||||
|
#include "RicfCommandFileExecutor.h"
|
||||||
|
|
||||||
|
#include "RiaApplication.h"
|
||||||
|
#include "RiaLogging.h"
|
||||||
|
#include "RiaProjectModifier.h"
|
||||||
|
|
||||||
|
CAF_PDM_SOURCE_INIT(RicfReplaceCase, "replaceCase");
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
RicfReplaceCase::RicfReplaceCase()
|
||||||
|
{
|
||||||
|
RICF_InitField(&m_caseId, "case", -1, "Case ID", "", "", "");
|
||||||
|
RICF_InitField(&m_newGridFile, "newGridFile", QString(), "New Grid File", "", "", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicfReplaceCase::execute()
|
||||||
|
{
|
||||||
|
if (m_newGridFile().isNull())
|
||||||
|
{
|
||||||
|
RiaLogging::error("replaceCase: Required parameter newGridFile.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString lastProjectPath = RicfCommandFileExecutor::instance()->getLastProjectPath();
|
||||||
|
if (lastProjectPath.isNull())
|
||||||
|
{
|
||||||
|
RiaLogging::error("replaceCase: 'openProject' must be called before 'replaceCase' to specify project file to replace case in.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
cvf::ref<RiaProjectModifier> projectModifier;
|
||||||
|
if (m_caseId() == -1)
|
||||||
|
{
|
||||||
|
projectModifier->setReplaceCaseFirstOccurrence(m_newGridFile());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
projectModifier->setReplaceCase(m_caseId(), m_newGridFile());
|
||||||
|
}
|
||||||
|
|
||||||
|
RiaApplication::instance()->loadProject(lastProjectPath, RiaApplication::PLA_NONE, projectModifier.p());
|
||||||
|
}
|
||||||
36
ApplicationCode/CommandFileInterface/RicfReplaceCase.h
Normal file
36
ApplicationCode/CommandFileInterface/RicfReplaceCase.h
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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 "RicfCommandObject.h"
|
||||||
|
|
||||||
|
#include "cafPdmField.h"
|
||||||
|
|
||||||
|
class RicfReplaceCase : public RicfCommandObject
|
||||||
|
{
|
||||||
|
CAF_PDM_HEADER_INIT;
|
||||||
|
|
||||||
|
public:
|
||||||
|
RicfReplaceCase();
|
||||||
|
|
||||||
|
virtual void execute() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
caf::PdmField<QString> m_newGridFile;
|
||||||
|
caf::PdmField<int> m_caseId;
|
||||||
|
};
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
#include "RicfSetTimeStep.h"
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Copyright (C) 2017 Statoil ASA
|
// Copyright (C) 2017 Statoil ASA
|
||||||
|
|||||||
Reference in New Issue
Block a user