mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4683 clang-format on all files in ApplicationCode
This commit is contained in:
@@ -2,17 +2,17 @@
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -33,10 +33,10 @@
|
||||
#include <QAction>
|
||||
#include <QFileDialog>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicAddScriptPathFeature, "RicAddScriptPathFeature");
|
||||
CAF_CMD_SOURCE_INIT( RicAddScriptPathFeature, "RicAddScriptPathFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicAddScriptPathFeature::isCommandEnabled()
|
||||
{
|
||||
@@ -45,17 +45,18 @@ bool RicAddScriptPathFeature::isCommandEnabled()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicAddScriptPathFeature::onActionTriggered(bool isChecked)
|
||||
void RicAddScriptPathFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
QString selectedFolder = QFileDialog::getExistingDirectory(Riu3DMainWindowTools::mainWindowWidget(), "Select script folder");
|
||||
if (!selectedFolder.isEmpty())
|
||||
QString selectedFolder = QFileDialog::getExistingDirectory( Riu3DMainWindowTools::mainWindowWidget(),
|
||||
"Select script folder" );
|
||||
if ( !selectedFolder.isEmpty() )
|
||||
{
|
||||
QString filePathString = RiaApplication::instance()->preferences()->scriptDirectories();
|
||||
|
||||
QChar separator(';');
|
||||
if (!filePathString.isEmpty() && !filePathString.endsWith(separator, Qt::CaseInsensitive))
|
||||
QChar separator( ';' );
|
||||
if ( !filePathString.isEmpty() && !filePathString.endsWith( separator, Qt::CaseInsensitive ) )
|
||||
{
|
||||
filePathString += separator;
|
||||
}
|
||||
@@ -70,9 +71,9 @@ void RicAddScriptPathFeature::onActionTriggered(bool isChecked)
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicAddScriptPathFeature::setupActionLook(QAction* actionToSetup)
|
||||
void RicAddScriptPathFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText("Add Script Path");
|
||||
actionToSetup->setText( "Add Script Path" );
|
||||
}
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -24,7 +24,7 @@
|
||||
#include <vector>
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicAddScriptPathFeature : public caf::CmdFeature
|
||||
{
|
||||
@@ -36,5 +36,3 @@ protected:
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -33,10 +33,10 @@
|
||||
#include <QAction>
|
||||
#include <QStringList>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicDeleteScriptPathFeature, "RicDeleteScriptPathFeature");
|
||||
CAF_CMD_SOURCE_INIT( RicDeleteScriptPathFeature, "RicDeleteScriptPathFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicDeleteScriptPathFeature::isCommandEnabled()
|
||||
{
|
||||
@@ -45,20 +45,20 @@ bool RicDeleteScriptPathFeature::isCommandEnabled()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicDeleteScriptPathFeature::onActionTriggered(bool isChecked)
|
||||
void RicDeleteScriptPathFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
std::vector<RimScriptCollection*> calcScriptCollections = RicScriptFeatureImpl::selectedScriptCollections();
|
||||
RimScriptCollection* scriptCollection = calcScriptCollections.size() > 0 ? calcScriptCollections[0] : nullptr;
|
||||
if (scriptCollection)
|
||||
if ( scriptCollection )
|
||||
{
|
||||
QString toBeRemoved = scriptCollection->directory;
|
||||
|
||||
QString originalFilePathString = RiaApplication::instance()->preferences()->scriptDirectories();
|
||||
QStringList allFilePaths = originalFilePathString.split(";");
|
||||
allFilePaths.removeOne(toBeRemoved);
|
||||
QString filePathString = allFilePaths.join(";");
|
||||
QString originalFilePathString = RiaApplication::instance()->preferences()->scriptDirectories();
|
||||
QStringList allFilePaths = originalFilePathString.split( ";" );
|
||||
allFilePaths.removeOne( toBeRemoved );
|
||||
QString filePathString = allFilePaths.join( ";" );
|
||||
|
||||
RiaApplication::instance()->preferences()->scriptDirectories = filePathString;
|
||||
RiaApplication::instance()->applyPreferences();
|
||||
@@ -68,11 +68,11 @@ void RicDeleteScriptPathFeature::onActionTriggered(bool isChecked)
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicDeleteScriptPathFeature::setupActionLook(QAction* actionToSetup)
|
||||
void RicDeleteScriptPathFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText("Delete Script Path");
|
||||
actionToSetup->setIcon(QIcon(":/Erase.png"));
|
||||
applyShortcutWithHintToAction(actionToSetup, QKeySequence::Delete);
|
||||
actionToSetup->setText( "Delete Script Path" );
|
||||
actionToSetup->setIcon( QIcon( ":/Erase.png" ) );
|
||||
applyShortcutWithHintToAction( actionToSetup, QKeySequence::Delete );
|
||||
}
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -24,7 +24,7 @@
|
||||
#include <vector>
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicDeleteScriptPathFeature : public caf::CmdFeature
|
||||
{
|
||||
@@ -36,5 +36,3 @@ protected:
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -21,8 +21,8 @@
|
||||
|
||||
#include "RicScriptFeatureImpl.h"
|
||||
|
||||
#include "RimCalcScript.h"
|
||||
#include "RiaApplication.h"
|
||||
#include "RimCalcScript.h"
|
||||
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
|
||||
@@ -32,10 +32,10 @@
|
||||
#include <QAction>
|
||||
#include <QMessageBox>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicEditScriptFeature, "RicEditScriptFeature");
|
||||
CAF_CMD_SOURCE_INIT( RicEditScriptFeature, "RicEditScriptFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicEditScriptFeature::isCommandEnabled()
|
||||
{
|
||||
@@ -44,37 +44,39 @@ bool RicEditScriptFeature::isCommandEnabled()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicEditScriptFeature::onActionTriggered(bool isChecked)
|
||||
void RicEditScriptFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
std::vector<RimCalcScript*> selection = RicScriptFeatureImpl::selectedScripts();
|
||||
CVF_ASSERT(selection.size() > 0);
|
||||
CVF_ASSERT( selection.size() > 0 );
|
||||
|
||||
RimCalcScript* calcScript = selection[0];
|
||||
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
QString scriptEditor = app->scriptEditorPath();
|
||||
if (!scriptEditor.isEmpty())
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
QString scriptEditor = app->scriptEditorPath();
|
||||
if ( !scriptEditor.isEmpty() )
|
||||
{
|
||||
QStringList arguments;
|
||||
arguments << calcScript->absoluteFileName;
|
||||
|
||||
QProcess* myProcess = new QProcess(this);
|
||||
myProcess->setProcessEnvironment(app->pythonProcessEnvironment());
|
||||
myProcess->start(scriptEditor, arguments);
|
||||
QProcess* myProcess = new QProcess( this );
|
||||
myProcess->setProcessEnvironment( app->pythonProcessEnvironment() );
|
||||
myProcess->start( scriptEditor, arguments );
|
||||
|
||||
if (!myProcess->waitForStarted(1000))
|
||||
if ( !myProcess->waitForStarted( 1000 ) )
|
||||
{
|
||||
QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), "Script editor", "Failed to start script editor executable\n" + scriptEditor);
|
||||
QMessageBox::warning( Riu3DMainWindowTools::mainWindowWidget(),
|
||||
"Script editor",
|
||||
"Failed to start script editor executable\n" + scriptEditor );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicEditScriptFeature::setupActionLook(QAction* actionToSetup)
|
||||
void RicEditScriptFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText("Edit");
|
||||
actionToSetup->setText( "Edit" );
|
||||
}
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -24,7 +24,7 @@
|
||||
#include <vector>
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicEditScriptFeature : public caf::CmdFeature
|
||||
{
|
||||
@@ -36,5 +36,3 @@ protected:
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -36,10 +36,10 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicExecuteScriptFeature, "RicExecuteScriptFeature");
|
||||
CAF_CMD_SOURCE_INIT( RicExecuteScriptFeature, "RicExecuteScriptFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicExecuteScriptFeature::isCommandEnabled()
|
||||
{
|
||||
@@ -48,12 +48,12 @@ bool RicExecuteScriptFeature::isCommandEnabled()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicExecuteScriptFeature::onActionTriggered(bool isChecked)
|
||||
void RicExecuteScriptFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
std::vector<RimCalcScript*> selection = RicScriptFeatureImpl::selectedScripts();
|
||||
CVF_ASSERT(selection.size() > 0);
|
||||
CVF_ASSERT( selection.size() > 0 );
|
||||
|
||||
RiuMainWindow* mainWindow = RiuMainWindow::instance();
|
||||
mainWindow->showProcessMonitorDockPanel();
|
||||
@@ -61,58 +61,58 @@ void RicExecuteScriptFeature::onActionTriggered(bool isChecked)
|
||||
RimCalcScript* calcScript = selection[0];
|
||||
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
if (calcScript->scriptType() == RimCalcScript::OCTAVE)
|
||||
if ( calcScript->scriptType() == RimCalcScript::OCTAVE )
|
||||
{
|
||||
QString octavePath = app->octavePath();
|
||||
if (!octavePath.isEmpty())
|
||||
if ( !octavePath.isEmpty() )
|
||||
{
|
||||
QStringList arguments = RimCalcScript::createCommandLineArguments(calcScript->absoluteFileName());
|
||||
RiaApplication::instance()->launchProcess(octavePath, arguments, app->octaveProcessEnvironment());
|
||||
QStringList arguments = RimCalcScript::createCommandLineArguments( calcScript->absoluteFileName() );
|
||||
RiaApplication::instance()->launchProcess( octavePath, arguments, app->octaveProcessEnvironment() );
|
||||
}
|
||||
}
|
||||
else if (calcScript->scriptType() == RimCalcScript::PYTHON)
|
||||
else if ( calcScript->scriptType() == RimCalcScript::PYTHON )
|
||||
{
|
||||
QString pythonPath = app->pythonPath();
|
||||
if (!pythonPath.isEmpty())
|
||||
if ( !pythonPath.isEmpty() )
|
||||
{
|
||||
QStringList arguments = RimCalcScript::createCommandLineArguments(calcScript->absoluteFileName());
|
||||
QProcessEnvironment penv = app->pythonProcessEnvironment();
|
||||
QStringList arguments = RimCalcScript::createCommandLineArguments( calcScript->absoluteFileName() );
|
||||
QProcessEnvironment penv = app->pythonProcessEnvironment();
|
||||
|
||||
RiuProcessMonitor* processMonitor = RiuMainWindow::instance()->processMonitor();
|
||||
if (RiaApplication::instance()->preferences()->showPythonDebugInfo() && processMonitor)
|
||||
if ( RiaApplication::instance()->preferences()->showPythonDebugInfo() && processMonitor )
|
||||
{
|
||||
QStringList debugInfo;
|
||||
debugInfo << "----- Launching Python interpreter -----";
|
||||
debugInfo << "Python interpreter path: " + pythonPath;
|
||||
debugInfo << "Using arguments: ";
|
||||
for (QString argument : arguments)
|
||||
for ( QString argument : arguments )
|
||||
{
|
||||
debugInfo << "* " + argument;
|
||||
}
|
||||
QStringList envList = penv.toStringList();
|
||||
debugInfo << "Using environment: ";
|
||||
for (QString envVariable : envList)
|
||||
for ( QString envVariable : envList )
|
||||
{
|
||||
debugInfo << "* " + envVariable;
|
||||
}
|
||||
|
||||
debugInfo << "------------------------------------";
|
||||
|
||||
for (QString debugString : debugInfo)
|
||||
for ( QString debugString : debugInfo )
|
||||
{
|
||||
std::cout << debugString.toStdString() << std::endl;
|
||||
processMonitor->addStringToLog(debugString + "\n");
|
||||
processMonitor->addStringToLog( debugString + "\n" );
|
||||
}
|
||||
}
|
||||
RiaApplication::instance()->launchProcess(pythonPath, arguments, penv);
|
||||
RiaApplication::instance()->launchProcess( pythonPath, arguments, penv );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicExecuteScriptFeature::setupActionLook(QAction* actionToSetup)
|
||||
void RicExecuteScriptFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText("Execute");
|
||||
actionToSetup->setText( "Execute" );
|
||||
}
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -24,7 +24,7 @@
|
||||
#include <vector>
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicExecuteScriptFeature : public caf::CmdFeature
|
||||
{
|
||||
@@ -36,5 +36,3 @@ protected:
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -21,8 +21,8 @@
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RimCalcScript.h"
|
||||
#include "RimCase.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
@@ -31,17 +31,17 @@
|
||||
#include <QAction>
|
||||
#include <QFileInfo>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicExecuteScriptForCasesFeature, "RicExecuteScriptForCasesFeature");
|
||||
CAF_CMD_SOURCE_INIT( RicExecuteScriptForCasesFeature, "RicExecuteScriptForCasesFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicExecuteScriptForCasesFeature::isCommandEnabled()
|
||||
{
|
||||
std::vector<RimCase*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||
caf::SelectionManager::instance()->objectsByType( &selection );
|
||||
|
||||
if (selection.size() > 0)
|
||||
if ( selection.size() > 0 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -52,43 +52,46 @@ bool RicExecuteScriptForCasesFeature::isCommandEnabled()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicExecuteScriptForCasesFeature::onActionTriggered(bool isChecked)
|
||||
void RicExecuteScriptForCasesFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
QString scriptAbsolutePath = userData().toString();
|
||||
|
||||
RiuMainWindow* mainWindow = RiuMainWindow::instance();
|
||||
mainWindow->showProcessMonitorDockPanel();
|
||||
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
QString octavePath = app->octavePath();
|
||||
if (!octavePath.isEmpty())
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
QString octavePath = app->octavePath();
|
||||
if ( !octavePath.isEmpty() )
|
||||
{
|
||||
QStringList arguments = RimCalcScript::createCommandLineArguments(scriptAbsolutePath);
|
||||
QStringList arguments = RimCalcScript::createCommandLineArguments( scriptAbsolutePath );
|
||||
|
||||
std::vector<RimCase*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||
caf::SelectionManager::instance()->objectsByType( &selection );
|
||||
|
||||
// Get case ID from selected cases in selection model
|
||||
std::vector<int> caseIdsInSelection;
|
||||
for (size_t i = 0; i < selection.size(); i++)
|
||||
for ( size_t i = 0; i < selection.size(); i++ )
|
||||
{
|
||||
RimCase* casePtr = selection[i];
|
||||
caseIdsInSelection.push_back(casePtr->caseId);
|
||||
caseIdsInSelection.push_back( casePtr->caseId );
|
||||
}
|
||||
|
||||
if (caseIdsInSelection.size() > 0)
|
||||
if ( caseIdsInSelection.size() > 0 )
|
||||
{
|
||||
RiaApplication::instance()->launchProcessForMultipleCases(octavePath, arguments, caseIdsInSelection, app->octaveProcessEnvironment());
|
||||
RiaApplication::instance()->launchProcessForMultipleCases( octavePath,
|
||||
arguments,
|
||||
caseIdsInSelection,
|
||||
app->octaveProcessEnvironment() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicExecuteScriptForCasesFeature::setupActionLook(QAction* actionToSetup)
|
||||
void RicExecuteScriptForCasesFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText("Execute script");
|
||||
actionToSetup->setText( "Execute script" );
|
||||
}
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -21,9 +21,8 @@
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicExecuteScriptForCasesFeature : public caf::CmdFeature
|
||||
{
|
||||
@@ -36,5 +35,3 @@ protected:
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -38,20 +38,20 @@
|
||||
#include <QLineEdit>
|
||||
#include <QMessageBox>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicNewOctaveScriptFeature, "RicNewOctaveScriptFeature");
|
||||
CAF_CMD_SOURCE_INIT( RicNewOctaveScriptFeature, "RicNewOctaveScriptFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicNewOctaveScriptFeature::isCommandEnabled()
|
||||
{
|
||||
std::vector<RimCalcScript*> calcScripts = RicScriptFeatureImpl::selectedScripts();
|
||||
std::vector<RimScriptCollection*> calcScriptCollections = RicScriptFeatureImpl::selectedScriptCollections();
|
||||
if (calcScripts.size() == 1u && calcScripts.front()->scriptType() == RimCalcScript::OCTAVE)
|
||||
if ( calcScripts.size() == 1u && calcScripts.front()->scriptType() == RimCalcScript::OCTAVE )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (calcScriptCollections.size() == 1u && !calcScriptCollections.front()->directory().isEmpty())
|
||||
else if ( calcScriptCollections.size() == 1u && !calcScriptCollections.front()->directory().isEmpty() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -59,24 +59,24 @@ bool RicNewOctaveScriptFeature::isCommandEnabled()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewOctaveScriptFeature::onActionTriggered(bool isChecked)
|
||||
void RicNewOctaveScriptFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
std::vector<RimCalcScript*> calcScripts = RicScriptFeatureImpl::selectedScripts();
|
||||
std::vector<RimCalcScript*> calcScripts = RicScriptFeatureImpl::selectedScripts();
|
||||
std::vector<RimScriptCollection*> calcScriptCollections = RicScriptFeatureImpl::selectedScriptCollections();
|
||||
|
||||
RimCalcScript* calcScript = calcScripts.size() > 0 ? calcScripts[0] : nullptr;
|
||||
RimCalcScript* calcScript = calcScripts.size() > 0 ? calcScripts[0] : nullptr;
|
||||
RimScriptCollection* scriptColl = calcScriptCollections.size() > 0 ? calcScriptCollections[0] : nullptr;
|
||||
|
||||
QString fullPathNewScript;
|
||||
|
||||
if (calcScript)
|
||||
if ( calcScript )
|
||||
{
|
||||
QFileInfo existingScriptFileInfo(calcScript->absoluteFileName());
|
||||
QFileInfo existingScriptFileInfo( calcScript->absoluteFileName() );
|
||||
fullPathNewScript = existingScriptFileInfo.absolutePath();
|
||||
}
|
||||
else if (scriptColl)
|
||||
else if ( scriptColl )
|
||||
{
|
||||
fullPathNewScript = scriptColl->directory();
|
||||
}
|
||||
@@ -88,61 +88,65 @@ void RicNewOctaveScriptFeature::onActionTriggered(bool isChecked)
|
||||
QString fullPathFilenameNewScript;
|
||||
|
||||
fullPathFilenameNewScript = fullPathNewScript + "/untitled.m";
|
||||
int num= 1;
|
||||
while (caf::Utils::fileExists(fullPathFilenameNewScript))
|
||||
int num = 1;
|
||||
while ( caf::Utils::fileExists( fullPathFilenameNewScript ) )
|
||||
{
|
||||
fullPathFilenameNewScript = fullPathNewScript + "/untitled" + QString::number(num) + ".m";
|
||||
fullPathFilenameNewScript = fullPathNewScript + "/untitled" + QString::number( num ) + ".m";
|
||||
num++;
|
||||
}
|
||||
|
||||
bool ok;
|
||||
fullPathFilenameNewScript = QInputDialog::getText(nullptr,
|
||||
"Specify new script file",
|
||||
"File name",
|
||||
QLineEdit::Normal,
|
||||
fullPathFilenameNewScript,
|
||||
&ok,
|
||||
RiuTools::defaultDialogFlags());
|
||||
fullPathFilenameNewScript = QInputDialog::getText( nullptr,
|
||||
"Specify new script file",
|
||||
"File name",
|
||||
QLineEdit::Normal,
|
||||
fullPathFilenameNewScript,
|
||||
&ok,
|
||||
RiuTools::defaultDialogFlags() );
|
||||
|
||||
if (ok && !fullPathFilenameNewScript.isEmpty())
|
||||
if ( ok && !fullPathFilenameNewScript.isEmpty() )
|
||||
{
|
||||
QFile file(fullPathFilenameNewScript);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
QFile file( fullPathFilenameNewScript );
|
||||
if ( !file.open( QIODevice::WriteOnly | QIODevice::Text ) )
|
||||
{
|
||||
QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), "Script editor", "Failed to create file\n" + fullPathFilenameNewScript);
|
||||
QMessageBox::warning( Riu3DMainWindowTools::mainWindowWidget(),
|
||||
"Script editor",
|
||||
"Failed to create file\n" + fullPathFilenameNewScript );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
RicRefreshScriptsFeature::refreshScriptFolders();
|
||||
|
||||
if (calcScript)
|
||||
if ( calcScript )
|
||||
{
|
||||
Riu3DMainWindowTools::selectAsCurrentItem(calcScript);
|
||||
Riu3DMainWindowTools::selectAsCurrentItem( calcScript );
|
||||
}
|
||||
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
QString scriptEditor = app->scriptEditorPath();
|
||||
if (!scriptEditor.isEmpty())
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
QString scriptEditor = app->scriptEditorPath();
|
||||
if ( !scriptEditor.isEmpty() )
|
||||
{
|
||||
QStringList arguments;
|
||||
arguments << fullPathFilenameNewScript;
|
||||
|
||||
QProcess* myProcess = new QProcess(this);
|
||||
myProcess->start(scriptEditor, arguments);
|
||||
QProcess* myProcess = new QProcess( this );
|
||||
myProcess->start( scriptEditor, arguments );
|
||||
|
||||
if (!myProcess->waitForStarted(1000))
|
||||
if ( !myProcess->waitForStarted( 1000 ) )
|
||||
{
|
||||
QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), "Script editor", "Failed to start script editor executable\n" + scriptEditor);
|
||||
QMessageBox::warning( Riu3DMainWindowTools::mainWindowWidget(),
|
||||
"Script editor",
|
||||
"Failed to start script editor executable\n" + scriptEditor );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewOctaveScriptFeature::setupActionLook(QAction* actionToSetup)
|
||||
void RicNewOctaveScriptFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText("New Octave Script");
|
||||
actionToSetup->setText( "New Octave Script" );
|
||||
}
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -24,7 +24,7 @@
|
||||
#include <vector>
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicNewOctaveScriptFeature : public caf::CmdFeature
|
||||
{
|
||||
@@ -36,5 +36,3 @@ protected:
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -38,30 +38,30 @@
|
||||
#include <QLineEdit>
|
||||
#include <QMessageBox>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicNewPythonScriptFeature, "RicNewPythonScriptFeature");
|
||||
CAF_CMD_SOURCE_INIT( RicNewPythonScriptFeature, "RicNewPythonScriptFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicNewPythonScriptFeature::isCommandEnabled()
|
||||
{
|
||||
std::vector<RimCalcScript*> calcScripts = RicScriptFeatureImpl::selectedScripts();
|
||||
std::vector<RimCalcScript*> calcScripts = RicScriptFeatureImpl::selectedScripts();
|
||||
std::vector<RimScriptCollection*> calcScriptCollections = RicScriptFeatureImpl::selectedScriptCollections();
|
||||
if (calcScripts.size() == 1u && calcScripts.front()->scriptType() == RimCalcScript::PYTHON)
|
||||
if ( calcScripts.size() == 1u && calcScripts.front()->scriptType() == RimCalcScript::PYTHON )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (calcScriptCollections.size() == 1u && !calcScriptCollections.front()->directory().isEmpty())
|
||||
}
|
||||
else if ( calcScriptCollections.size() == 1u && !calcScriptCollections.front()->directory().isEmpty() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewPythonScriptFeature::onActionTriggered(bool isChecked)
|
||||
void RicNewPythonScriptFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
std::vector<RimCalcScript*> calcScripts = RicScriptFeatureImpl::selectedScripts();
|
||||
std::vector<RimScriptCollection*> calcScriptCollections = RicScriptFeatureImpl::selectedScriptCollections();
|
||||
@@ -71,13 +71,13 @@ void RicNewPythonScriptFeature::onActionTriggered(bool isChecked)
|
||||
|
||||
QString fullPathNewScript;
|
||||
|
||||
if (calcScript)
|
||||
if ( calcScript )
|
||||
{
|
||||
QFileInfo existingScriptFileInfo(calcScript->absoluteFileName());
|
||||
QFileInfo existingScriptFileInfo( calcScript->absoluteFileName() );
|
||||
fullPathNewScript = existingScriptFileInfo.absolutePath();
|
||||
calcScript->firstAncestorOrThisOfTypeAsserted(scriptColl);
|
||||
calcScript->firstAncestorOrThisOfTypeAsserted( scriptColl );
|
||||
}
|
||||
else if (scriptColl)
|
||||
else if ( scriptColl )
|
||||
{
|
||||
fullPathNewScript = scriptColl->directory();
|
||||
}
|
||||
@@ -90,60 +90,63 @@ void RicNewPythonScriptFeature::onActionTriggered(bool isChecked)
|
||||
|
||||
fullPathFilenameNewScript = fullPathNewScript + "/untitled.py";
|
||||
int num = 1;
|
||||
while (caf::Utils::fileExists(fullPathFilenameNewScript))
|
||||
while ( caf::Utils::fileExists( fullPathFilenameNewScript ) )
|
||||
{
|
||||
fullPathFilenameNewScript = fullPathNewScript + "/untitled" + QString::number(num) + ".py";
|
||||
fullPathFilenameNewScript = fullPathNewScript + "/untitled" + QString::number( num ) + ".py";
|
||||
num++;
|
||||
}
|
||||
|
||||
bool ok;
|
||||
fullPathFilenameNewScript = QInputDialog::getText(nullptr,
|
||||
"Specify new script file",
|
||||
"File name",
|
||||
QLineEdit::Normal,
|
||||
fullPathFilenameNewScript,
|
||||
&ok,
|
||||
RiuTools::defaultDialogFlags());
|
||||
fullPathFilenameNewScript = QInputDialog::getText( nullptr,
|
||||
"Specify new script file",
|
||||
"File name",
|
||||
QLineEdit::Normal,
|
||||
fullPathFilenameNewScript,
|
||||
&ok,
|
||||
RiuTools::defaultDialogFlags() );
|
||||
|
||||
if (ok && !fullPathFilenameNewScript.isEmpty())
|
||||
if ( ok && !fullPathFilenameNewScript.isEmpty() )
|
||||
{
|
||||
QFile file(fullPathFilenameNewScript);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
QFile file( fullPathFilenameNewScript );
|
||||
if ( !file.open( QIODevice::WriteOnly | QIODevice::Text ) )
|
||||
{
|
||||
QMessageBox::warning(
|
||||
Riu3DMainWindowTools::mainWindowWidget(), "Script editor", "Failed to create file\n" + fullPathFilenameNewScript);
|
||||
QMessageBox::warning( Riu3DMainWindowTools::mainWindowWidget(),
|
||||
"Script editor",
|
||||
"Failed to create file\n" + fullPathFilenameNewScript );
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
QTextStream stream(&file);
|
||||
stream << "# Load ResInsight Processing Server Client Library\nimport rips\n# Connect to ResInsight instance\nresInsight = rips.Instance.find()\n# Example code\nprint(\"ResInsight version: \" + resInsight.app.versionString())\n";
|
||||
QTextStream stream( &file );
|
||||
stream << "# Load ResInsight Processing Server Client Library\nimport rips\n# Connect to ResInsight "
|
||||
"instance\nresInsight = rips.Instance.find()\n# Example code\nprint(\"ResInsight version: \" + "
|
||||
"resInsight.app.versionString())\n";
|
||||
}
|
||||
|
||||
scriptColl->readContentFromDisc();
|
||||
scriptColl->updateConnectedEditors();
|
||||
|
||||
if (calcScript)
|
||||
if ( calcScript )
|
||||
{
|
||||
Riu3DMainWindowTools::selectAsCurrentItem(calcScript);
|
||||
Riu3DMainWindowTools::selectAsCurrentItem( calcScript );
|
||||
}
|
||||
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
QString scriptEditor = app->scriptEditorPath();
|
||||
if (!scriptEditor.isEmpty())
|
||||
if ( !scriptEditor.isEmpty() )
|
||||
{
|
||||
QStringList arguments;
|
||||
arguments << fullPathFilenameNewScript;
|
||||
|
||||
QProcess* myProcess = new QProcess(this);
|
||||
myProcess->start(scriptEditor, arguments);
|
||||
QProcess* myProcess = new QProcess( this );
|
||||
myProcess->start( scriptEditor, arguments );
|
||||
|
||||
if (!myProcess->waitForStarted(1000))
|
||||
if ( !myProcess->waitForStarted( 1000 ) )
|
||||
{
|
||||
QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(),
|
||||
"Script editor",
|
||||
"Failed to start script editor executable\n" + scriptEditor);
|
||||
QMessageBox::warning( Riu3DMainWindowTools::mainWindowWidget(),
|
||||
"Script editor",
|
||||
"Failed to start script editor executable\n" + scriptEditor );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -152,11 +155,7 @@ void RicNewPythonScriptFeature::onActionTriggered(bool isChecked)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewPythonScriptFeature::setupActionLook(QAction* actionToSetup)
|
||||
void RicNewPythonScriptFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText("New Python Script");
|
||||
actionToSetup->setText( "New Python Script" );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -32,6 +32,6 @@ class RicNewPythonScriptFeature : public caf::CmdFeature
|
||||
protected:
|
||||
// Overrides
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered(bool isChecked) override;
|
||||
void setupActionLook(QAction* actionToSetup) override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2016 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -26,10 +26,10 @@
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicRefreshScriptsFeature, "RicRefreshScriptsFeature");
|
||||
CAF_CMD_SOURCE_INIT( RicRefreshScriptsFeature, "RicRefreshScriptsFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicRefreshScriptsFeature::isCommandEnabled()
|
||||
{
|
||||
@@ -37,30 +37,30 @@ bool RicRefreshScriptsFeature::isCommandEnabled()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicRefreshScriptsFeature::onActionTriggered(bool isChecked)
|
||||
void RicRefreshScriptsFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
refreshScriptFolders();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicRefreshScriptsFeature::setupActionLook(QAction* actionToSetup)
|
||||
void RicRefreshScriptsFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText("Refresh");
|
||||
actionToSetup->setIcon(QIcon(":/Refresh-32.png"));
|
||||
actionToSetup->setText( "Refresh" );
|
||||
actionToSetup->setIcon( QIcon( ":/Refresh-32.png" ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicRefreshScriptsFeature::refreshScriptFolders()
|
||||
{
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
RiaPreferences* prefs = RiaApplication::instance()->preferences();
|
||||
|
||||
proj->setScriptDirectories(prefs->scriptDirectories());
|
||||
proj->setScriptDirectories( prefs->scriptDirectories() );
|
||||
proj->scriptCollection()->updateConnectedEditors();
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2016 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <vector>
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicRefreshScriptsFeature : public caf::CmdFeature
|
||||
{
|
||||
@@ -38,5 +38,3 @@ protected:
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -24,23 +24,23 @@
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimCalcScript*> RicScriptFeatureImpl::selectedScripts()
|
||||
{
|
||||
std::vector<RimCalcScript*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||
caf::SelectionManager::instance()->objectsByType( &selection );
|
||||
|
||||
return selection;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimScriptCollection*> RicScriptFeatureImpl::selectedScriptCollections()
|
||||
{
|
||||
std::vector<RimScriptCollection*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||
caf::SelectionManager::instance()->objectsByType( &selection );
|
||||
|
||||
return selection;
|
||||
}
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -27,13 +27,11 @@ class RimCalcScript;
|
||||
class RimScriptCollection;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicScriptFeatureImpl
|
||||
{
|
||||
public:
|
||||
static std::vector<RimCalcScript*> selectedScripts();
|
||||
static std::vector<RimScriptCollection*> selectedScriptCollections();
|
||||
static std::vector<RimCalcScript*> selectedScripts();
|
||||
static std::vector<RimScriptCollection*> selectedScriptCollections();
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user