mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4285 Octave : Move creation of command line arguments to RimCalcScript
This commit is contained in:
parent
fd774bec39
commit
7af16ce24c
@ -22,6 +22,8 @@
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaLogging.h"
|
||||
|
||||
#include "RimCalcScript.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RicfRunOctaveScript, "runOctaveScript");
|
||||
@ -41,11 +43,8 @@ RicfRunOctaveScript::RicfRunOctaveScript()
|
||||
void RicfRunOctaveScript::execute()
|
||||
{
|
||||
QString octavePath = RiaApplication::instance()->octavePath();
|
||||
QFileInfo scriptFileInfo(m_path());
|
||||
QStringList processArguments;
|
||||
|
||||
processArguments << "--path" << scriptFileInfo.absolutePath();
|
||||
processArguments << scriptFileInfo.absoluteFilePath();
|
||||
QStringList processArguments = RimCalcScript::createCommandLineArguments(m_path());
|
||||
|
||||
bool ok;
|
||||
if (m_caseIds().empty())
|
||||
|
@ -59,15 +59,7 @@ void RicExecuteScriptFeature::onActionTriggered(bool isChecked)
|
||||
QString octavePath = app->octavePath();
|
||||
if (!octavePath.isEmpty())
|
||||
{
|
||||
// TODO: Must rename RimCalcScript::absolutePath to absoluteFileName, as the code below is confusing
|
||||
// absolutePath() is a function in QFileInfo
|
||||
QFileInfo fi(calcScript->absoluteFileName());
|
||||
QString octaveFunctionSearchPath = fi.absolutePath();
|
||||
|
||||
QStringList arguments = app->octaveArguments();
|
||||
arguments.append("--path");
|
||||
arguments << octaveFunctionSearchPath;
|
||||
arguments << calcScript->absoluteFileName();
|
||||
QStringList arguments = RimCalcScript::createCommandLineArguments(calcScript->absoluteFileName());
|
||||
|
||||
RiaApplication::instance()->launchProcess(octavePath, arguments);
|
||||
}
|
||||
|
@ -19,8 +19,11 @@
|
||||
|
||||
#include "RicExecuteScriptForCasesFeature.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RimCalcScript.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
@ -62,16 +65,7 @@ void RicExecuteScriptForCasesFeature::onActionTriggered(bool isChecked)
|
||||
QString octavePath = app->octavePath();
|
||||
if (!octavePath.isEmpty())
|
||||
{
|
||||
// TODO: Must rename RimCalcScript::absolutePath to absoluteFileName, as the code below is confusing
|
||||
// absolutePath() is a function in QFileInfo
|
||||
|
||||
QFileInfo fi(scriptAbsolutePath);
|
||||
QString octaveFunctionSearchPath = fi.absolutePath();
|
||||
|
||||
QStringList arguments = app->octaveArguments();
|
||||
arguments.append("--path");
|
||||
arguments << octaveFunctionSearchPath;
|
||||
arguments << scriptAbsolutePath;
|
||||
QStringList arguments = RimCalcScript::createCommandLineArguments(scriptAbsolutePath);
|
||||
|
||||
std::vector<RimCase*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||
|
@ -18,11 +18,14 @@
|
||||
|
||||
#include "RimCalcScript.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaFieldHandleTools.h"
|
||||
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmUiFilePathEditor.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimCalcScript, "CalcScript");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -43,3 +46,22 @@ RimCalcScript::RimCalcScript()
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimCalcScript::~RimCalcScript() {}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QStringList RimCalcScript::createCommandLineArguments(const QString& absoluteFileName)
|
||||
{
|
||||
QFileInfo fi(absoluteFileName);
|
||||
QString octaveFunctionSearchPath = fi.absolutePath();
|
||||
|
||||
auto app = RiaApplication::instance();
|
||||
|
||||
QStringList arguments = app->octaveArguments();
|
||||
arguments.append("--path");
|
||||
|
||||
arguments << octaveFunctionSearchPath;
|
||||
arguments << absoluteFileName;
|
||||
|
||||
return arguments;
|
||||
}
|
||||
|
@ -33,6 +33,8 @@ public:
|
||||
RimCalcScript();
|
||||
~RimCalcScript() override;
|
||||
|
||||
static QStringList createCommandLineArguments(const QString& absoluteFileName);
|
||||
|
||||
caf::PdmField<QString> absoluteFileName;
|
||||
caf::PdmField<QString> content; // TODO: Obsolete field, can be deleted on next project file revision.
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user