Files
ResInsight/ApplicationLibCode/CommandFileInterface/RicfRunOctaveScript.cpp
T
Kristian Bendiksen b1a822e7ac #14772 Python: Add Project.run_octave_script as object method and forward runOctaveScript to it
RimProject_runOctaveScript takes Case objects (empty means all Eclipse
cases) and runs the script once per case through the existing
multi-case process launcher. RicfRunOctaveScript resolves the case ids
and forwards to it.
2026-09-22 14:19:23 +02:00

62 lines
2.2 KiB
C++

#include "RicfRunOctaveScript.h"
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicfRunOctaveScript.h"
#include "RicfCommandForwarding.h"
#include "RimCase.h"
#include "RimProject.h"
#include "RimcProject.h"
#include "cafPdmFieldScriptingCapability.h"
CAF_PDM_SOURCE_INIT( RicfRunOctaveScript, "runOctaveScript" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfRunOctaveScript::RicfRunOctaveScript()
{
CAF_PDM_InitScriptableField( &m_path, "path", QString(), "Path" );
CAF_PDM_InitScriptableField( &m_caseIds, "caseIds", std::vector<int>(), "Case IDs" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmScriptResponse RicfRunOctaveScript::execute()
{
const QString commandName = classKeyword();
std::vector<RimCase*> cases;
for ( int caseId : m_caseIds() )
{
auto rimCase = RicfForwarding::findCase( caseId );
if ( !rimCase ) return RicfForwarding::errorResponse( rimCase.error(), commandName );
cases.push_back( rimCase.value() );
}
RimProject_runOctaveScript method( RimProject::current() );
method.setPath( m_path() );
method.setCases( cases );
return RicfForwarding::toScriptResponse( method.execute(), commandName );
}