diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 28c6de9612..79b9a501bf 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -1066,6 +1066,34 @@ QString RiaApplication::octavePath() const return m_preferences->octaveExecutable(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RiaApplication::octaveArguments() const +{ + // http://www.gnu.org/software/octave/doc/interpreter/Command-Line-Options.html#Command-Line-Options + + // -p path + // Add path to the head of the search path for function files. The value of path specified on the command line + // will override any value of OCTAVE_PATH found in the environment, but not any commands in the system or + // user startup files that set the internal load path through one of the path functions. + + + QStringList arguments; + arguments.append("--path"); + arguments << QApplication::applicationDirPath(); + + if (!m_preferences->octaveShowHeaderInfoWhenExecutingScripts) + { + // -q + // Don't print the usual greeting and version message at startup. + + arguments.append("-q"); + } + + return arguments; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Application/RiaApplication.h b/ApplicationCode/Application/RiaApplication.h index f026d613b6..d15203870f 100644 --- a/ApplicationCode/Application/RiaApplication.h +++ b/ApplicationCode/Application/RiaApplication.h @@ -123,7 +123,9 @@ public: RINavigationPolicy navigationPolicy() const; QString scriptDirectories() const; QString scriptEditorPath() const; + QString octavePath() const; + QStringList octaveArguments() const; bool launchProcess(const QString& program, const QStringList& arguments); bool launchProcessForMultipleCases(const QString& program, const QStringList& arguments, const std::vector& caseIds); diff --git a/ApplicationCode/ProjectDataModel/RimCommandObject.cpp b/ApplicationCode/ProjectDataModel/RimCommandObject.cpp index f24c7bd956..858f936def 100644 --- a/ApplicationCode/ProjectDataModel/RimCommandObject.cpp +++ b/ApplicationCode/ProjectDataModel/RimCommandObject.cpp @@ -106,13 +106,7 @@ void RimCommandExecuteScript::redo() QString octavePath = app->octavePath(); if (!octavePath.isEmpty()) { - // http://www.gnu.org/software/octave/doc/interpreter/Command-Line-Options.html#Command-Line-Options - - QStringList arguments; - arguments.append("--path"); - arguments << QApplication::applicationDirPath(); - - arguments.append("-q"); + QStringList arguments = app->octaveArguments(); arguments.append("--eval"); arguments << this->scriptText(); diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index 690c0bdfa7..60bde2559f 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -538,29 +538,14 @@ void RimUiTreeView::slotExecuteScript() QString octavePath = app->octavePath(); if (!octavePath.isEmpty()) { - // http://www.gnu.org/software/octave/doc/interpreter/Command-Line-Options.html#Command-Line-Options - - // -p path - // Add path to the head of the search path for function files. The value of path specified on the command line - // will override any value of OCTAVE_PATH found in the environment, but not any commands in the system or - // user startup files that set the internal load path through one of the path functions. - - // -q - // Don't print the usual greeting and version message at startup. - - // TODO: Must rename RimCalcScript::absolutePath to absoluteFileName, as the code below is confusing // absolutePath() is a function in QFileInfo QFileInfo fi(calcScript->absolutePath()); QString octaveFunctionSearchPath = fi.absolutePath(); - QStringList arguments; + QStringList arguments = app->octaveArguments(); arguments.append("--path"); arguments << octaveFunctionSearchPath; - arguments.append("--path"); - arguments << QApplication::applicationDirPath(); - - arguments.append("-q"); arguments << calcScript->absolutePath(); RiaApplication::instance()->launchProcess(octavePath, arguments); @@ -593,29 +578,14 @@ void RimUiTreeView::slotExecuteScriptForSelectedCases() QString octavePath = app->octavePath(); if (!octavePath.isEmpty()) { - // http://www.gnu.org/software/octave/doc/interpreter/Command-Line-Options.html#Command-Line-Options - - // -p path - // Add path to the head of the search path for function files. The value of path specified on the command line - // will override any value of OCTAVE_PATH found in the environment, but not any commands in the system or - // user startup files that set the internal load path through one of the path functions. - - // -q - // Don't print the usual greeting and version message at startup. - - // TODO: Must rename RimCalcScript::absolutePath to absoluteFileName, as the code below is confusing // absolutePath() is a function in QFileInfo QFileInfo fi(calcScript->absolutePath()); QString octaveFunctionSearchPath = fi.absolutePath(); - QStringList arguments; + QStringList arguments = app->octaveArguments(); arguments.append("--path"); arguments << octaveFunctionSearchPath; - arguments.append("--path"); - arguments << QApplication::applicationDirPath(); - - arguments.append("-q"); arguments << calcScript->absolutePath(); // Get case ID from selected cases in selection model