mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-16 02:12:12 -05:00
#4471 Implement python script running and editor in ResInsight GUI, same as Octave.
This commit is contained in:
1 parent
8f464e5e23
commit
3ba962aefb
16 files changed
+200
-61
No files matched your search
@@ -48,6 +48,31 @@ RimCalcScript::RimCalcScript()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimCalcScript::~RimCalcScript() {}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimCalcScript::ScriptType RimCalcScript::scriptType(const QString& absoluteFileNameScript)
|
||||
{
|
||||
QFileInfo fileInfo(absoluteFileNameScript);
|
||||
if (fileInfo.suffix() == "py")
|
||||
{
|
||||
return PYTHON;
|
||||
}
|
||||
else if (fileInfo.suffix() == "m")
|
||||
{
|
||||
return OCTAVE;
|
||||
}
|
||||
return UNKNOWN;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimCalcScript::ScriptType RimCalcScript::scriptType() const
|
||||
{
|
||||
return scriptType(absoluteFileName());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -55,20 +80,27 @@ QStringList RimCalcScript::createCommandLineArguments(const QString& absoluteFil
|
||||
{
|
||||
QStringList arguments;
|
||||
|
||||
if (scriptType(absoluteFileNameScript) == PYTHON)
|
||||
{
|
||||
auto app = RiaApplication::instance();
|
||||
|
||||
arguments = app->octaveArguments();
|
||||
arguments.append("--path");
|
||||
arguments.append(absoluteFileNameScript);
|
||||
}
|
||||
|
||||
else if (scriptType(absoluteFileNameScript) == OCTAVE)
|
||||
{
|
||||
QFileInfo fi(absoluteFileNameScript);
|
||||
QString octaveFunctionSearchPath = fi.absolutePath();
|
||||
QString absFilePath = fi.absoluteFilePath();
|
||||
{
|
||||
auto app = RiaApplication::instance();
|
||||
|
||||
arguments << octaveFunctionSearchPath;
|
||||
arguments << absFilePath;
|
||||
arguments = app->octaveArguments();
|
||||
arguments.append("--path");
|
||||
}
|
||||
|
||||
{
|
||||
QFileInfo fi(absoluteFileNameScript);
|
||||
QString octaveFunctionSearchPath = fi.absolutePath();
|
||||
QString absFilePath = fi.absoluteFilePath();
|
||||
|
||||
arguments << octaveFunctionSearchPath;
|
||||
arguments << absFilePath;
|
||||
}
|
||||
}
|
||||
|
||||
bool debugPrintArgumentText = false;
|
||||
@@ -76,8 +108,19 @@ QStringList RimCalcScript::createCommandLineArguments(const QString& absoluteFil
|
||||
{
|
||||
QString argumentString = arguments.join(" ");
|
||||
|
||||
RiaLogging::info("Octave arguments : " + argumentString);
|
||||
RiaLogging::info("Scriptarguments : " + argumentString);
|
||||
}
|
||||
|
||||
return arguments;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCalcScript::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/)
|
||||
{
|
||||
if (scriptType() == PYTHON)
|
||||
{
|
||||
uiCapability()->setUiIconFromResourceString(":/PythonScriptFile16x16.png");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user