mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#339) Added RicExecuteScriptFeature
This commit is contained in:
parent
c52c029045
commit
d466d58164
@ -10,6 +10,7 @@ ${CEE_CURRENT_LIST_DIR}RicEclipseCaseExecuteScriptFeature.h
|
|||||||
${CEE_CURRENT_LIST_DIR}RicEclipseCaseNewGroupFeature.h
|
${CEE_CURRENT_LIST_DIR}RicEclipseCaseNewGroupFeature.h
|
||||||
${CEE_CURRENT_LIST_DIR}RicEclipseCaseNewGroupExec.h
|
${CEE_CURRENT_LIST_DIR}RicEclipseCaseNewGroupExec.h
|
||||||
${CEE_CURRENT_LIST_DIR}RicEclipseCasePasteFeature.h
|
${CEE_CURRENT_LIST_DIR}RicEclipseCasePasteFeature.h
|
||||||
|
${CEE_CURRENT_LIST_DIR}RicExecuteScriptFeature.h
|
||||||
${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterFeatureImpl.h
|
${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterFeatureImpl.h
|
||||||
${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterInsertFeature.h
|
${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterInsertFeature.h
|
||||||
${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterInsertExec.h
|
${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterInsertExec.h
|
||||||
@ -52,6 +53,7 @@ ${CEE_CURRENT_LIST_DIR}RicEclipseCaseExecuteScriptFeature.cpp
|
|||||||
${CEE_CURRENT_LIST_DIR}RicEclipseCaseNewGroupFeature.cpp
|
${CEE_CURRENT_LIST_DIR}RicEclipseCaseNewGroupFeature.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RicEclipseCaseNewGroupExec.cpp
|
${CEE_CURRENT_LIST_DIR}RicEclipseCaseNewGroupExec.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RicEclipseCasePasteFeature.cpp
|
${CEE_CURRENT_LIST_DIR}RicEclipseCasePasteFeature.cpp
|
||||||
|
${CEE_CURRENT_LIST_DIR}RicExecuteScriptFeature.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterFeatureImpl.cpp
|
${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterFeatureImpl.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterInsertFeature.cpp
|
${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterInsertFeature.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterInsertExec.cpp
|
${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterInsertExec.cpp
|
||||||
|
87
ApplicationCode/Commands/RicExecuteScriptFeature.cpp
Normal file
87
ApplicationCode/Commands/RicExecuteScriptFeature.cpp
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "RicExecuteScriptFeature.h"
|
||||||
|
|
||||||
|
#include "RimCalcScript.h"
|
||||||
|
#include "RiaApplication.h"
|
||||||
|
|
||||||
|
#include "cafSelectionManager.h"
|
||||||
|
#include "cvfAssert.h"
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
|
#include <QFileInfo>
|
||||||
|
|
||||||
|
CAF_CMD_SOURCE_INIT(RicExecuteScriptFeature, "RicExecuteScriptFeature");
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RicExecuteScriptFeature::isCommandEnabled()
|
||||||
|
{
|
||||||
|
std::vector<RimCalcScript*> selection = selectedScripts();
|
||||||
|
return selection.size() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicExecuteScriptFeature::onActionTriggered(bool isChecked)
|
||||||
|
{
|
||||||
|
std::vector<RimCalcScript*> selection = selectedScripts();
|
||||||
|
CVF_ASSERT(selection.size() > 0);
|
||||||
|
|
||||||
|
RimCalcScript* calcScript = selection[0];
|
||||||
|
|
||||||
|
RiaApplication* app = RiaApplication::instance();
|
||||||
|
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->absolutePath());
|
||||||
|
QString octaveFunctionSearchPath = fi.absolutePath();
|
||||||
|
|
||||||
|
QStringList arguments = app->octaveArguments();
|
||||||
|
arguments.append("--path");
|
||||||
|
arguments << octaveFunctionSearchPath;
|
||||||
|
arguments << calcScript->absolutePath();
|
||||||
|
|
||||||
|
RiaApplication::instance()->launchProcess(octavePath, arguments);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicExecuteScriptFeature::setupActionLook(QAction* actionToSetup)
|
||||||
|
{
|
||||||
|
actionToSetup->setText("Execute");
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
std::vector<RimCalcScript*> RicExecuteScriptFeature::selectedScripts()
|
||||||
|
{
|
||||||
|
std::vector<RimCalcScript*> selection;
|
||||||
|
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||||
|
|
||||||
|
return selection;
|
||||||
|
}
|
45
ApplicationCode/Commands/RicExecuteScriptFeature.h
Normal file
45
ApplicationCode/Commands/RicExecuteScriptFeature.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "cafCmdFeature.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
class RimCalcScript;
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
///
|
||||||
|
//==================================================================================================
|
||||||
|
class RicExecuteScriptFeature : public caf::CmdFeature
|
||||||
|
{
|
||||||
|
CAF_CMD_HEADER_INIT;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Overrides
|
||||||
|
virtual bool isCommandEnabled();
|
||||||
|
virtual void onActionTriggered( bool isChecked );
|
||||||
|
virtual void setupActionLook( QAction* actionToSetup );
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<RimCalcScript*> selectedScripts();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
@ -39,6 +39,7 @@
|
|||||||
#include "RimWellPath.h"
|
#include "RimWellPath.h"
|
||||||
#include "RimWellPathCollection.h"
|
#include "RimWellPathCollection.h"
|
||||||
#include "RimWellPathImport.h"
|
#include "RimWellPathImport.h"
|
||||||
|
#include "RimCalcScript.h"
|
||||||
|
|
||||||
#include "cafPdmUiTreeOrdering.h"
|
#include "cafPdmUiTreeOrdering.h"
|
||||||
|
|
||||||
@ -548,7 +549,7 @@ void RimProject::actionsBasedOnSelection(QMenu& contextMenu)
|
|||||||
{
|
{
|
||||||
commandIds << "RicCopyReferencesToClipboardFeature";
|
commandIds << "RicCopyReferencesToClipboardFeature";
|
||||||
}
|
}
|
||||||
else if (uiItems.size() == 1)
|
else if (uiItems.size() == 1)
|
||||||
{
|
{
|
||||||
caf::PdmUiItem* uiItem = uiItems[0];
|
caf::PdmUiItem* uiItem = uiItems[0];
|
||||||
CVF_ASSERT(uiItem);
|
CVF_ASSERT(uiItem);
|
||||||
@ -648,6 +649,10 @@ void RimProject::actionsBasedOnSelection(QMenu& contextMenu)
|
|||||||
{
|
{
|
||||||
commandIds << "RicDeleteItemFeature";
|
commandIds << "RicDeleteItemFeature";
|
||||||
}
|
}
|
||||||
|
else if (dynamic_cast<RimCalcScript*>(uiItem))
|
||||||
|
{
|
||||||
|
commandIds << "RicExecuteScriptFeature";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RicToggleItemsFeatureImpl::isToggleCommandsAvailable())
|
if (RicToggleItemsFeatureImpl::isToggleCommandsAvailable())
|
||||||
|
@ -596,6 +596,7 @@ void RimUiTreeView::slotNewScript()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
// OBSOLETE - see RicExecuteScriptFeature
|
||||||
void RimUiTreeView::slotExecuteScript()
|
void RimUiTreeView::slotExecuteScript()
|
||||||
{
|
{
|
||||||
QModelIndex index = currentIndex();
|
QModelIndex index = currentIndex();
|
||||||
|
Loading…
Reference in New Issue
Block a user