Aggregated common Octave argument list

This commit is contained in:
Magne Sjaastad 2014-07-22 12:11:48 +02:00
parent 329ec921e8
commit 31274dbb00
4 changed files with 33 additions and 39 deletions

View File

@ -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;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -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<int>& caseIds);

View File

@ -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();

View File

@ -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