2017-07-27 10:39:59 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2017 Statoil ASA
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
2017-07-27 10:39:59 +02:00
|
|
|
// 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.
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
2017-07-27 10:39:59 +02:00
|
|
|
// 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.
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2017-07-27 10:39:59 +02:00
|
|
|
// for more details.
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#include "RicfSetTimeStep.h"
|
|
|
|
|
|
2026-09-16 15:11:15 +02:00
|
|
|
#include "RicfCommandForwarding.h"
|
2017-07-27 10:39:59 +02:00
|
|
|
|
2026-09-16 15:11:15 +02:00
|
|
|
#include "Rim3dView.h"
|
|
|
|
|
#include "RimCase.h"
|
|
|
|
|
#include "RimcGridView.h"
|
2017-07-27 10:39:59 +02:00
|
|
|
|
2020-08-21 11:13:07 +02:00
|
|
|
#include "cafPdmFieldScriptingCapability.h"
|
2020-03-10 14:11:22 +01:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
CAF_PDM_SOURCE_INIT( RicfSetTimeStep, "setTimeStep" );
|
2017-07-27 10:39:59 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-07-27 10:39:59 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RicfSetTimeStep::RicfSetTimeStep()
|
|
|
|
|
{
|
2021-11-14 14:15:12 +01:00
|
|
|
CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "Case ID" );
|
|
|
|
|
CAF_PDM_InitScriptableField( &m_viewId, "viewId", -1, "View ID" );
|
|
|
|
|
CAF_PDM_InitScriptableField( &m_timeStepIndex, "timeStep", -1, "Time Step Index" );
|
2017-07-27 10:39:59 +02:00
|
|
|
}
|
|
|
|
|
|
2019-05-20 13:21:02 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
void RicfSetTimeStep::setCaseId( int caseId )
|
2019-05-20 13:21:02 +02:00
|
|
|
{
|
|
|
|
|
m_caseId = caseId;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-23 11:50:33 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RicfSetTimeStep::setViewId( int viewId )
|
|
|
|
|
{
|
|
|
|
|
m_viewId = viewId;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-20 13:21:02 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
void RicfSetTimeStep::setTimeStepIndex( int timeStepIndex )
|
2019-05-20 13:21:02 +02:00
|
|
|
{
|
|
|
|
|
m_timeStepIndex = timeStepIndex;
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-27 10:39:59 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-07-27 10:39:59 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-03-10 14:11:22 +01:00
|
|
|
caf::PdmScriptResponse RicfSetTimeStep::execute()
|
2017-07-27 10:39:59 +02:00
|
|
|
{
|
2026-09-16 15:11:15 +02:00
|
|
|
const QString commandName = classKeyword();
|
2017-07-27 10:39:59 +02:00
|
|
|
|
2026-09-16 15:11:15 +02:00
|
|
|
auto rimCase = RicfForwarding::findCase( m_caseId() );
|
|
|
|
|
if ( !rimCase ) return RicfForwarding::errorResponse( rimCase.error(), commandName );
|
2020-01-21 08:48:44 +01:00
|
|
|
|
2026-09-16 15:11:15 +02:00
|
|
|
// A view id of -1 applies the time step to all views of the case
|
|
|
|
|
std::vector<Rim3dView*> views;
|
|
|
|
|
if ( m_viewId() == -1 )
|
|
|
|
|
{
|
|
|
|
|
views = rimCase.value()->views();
|
2017-07-27 10:39:59 +02:00
|
|
|
}
|
2026-09-16 15:11:15 +02:00
|
|
|
else
|
2019-05-23 13:59:19 +02:00
|
|
|
{
|
2026-09-16 15:11:15 +02:00
|
|
|
auto view = RicfForwarding::findView( rimCase.value(), m_viewId() );
|
|
|
|
|
if ( !view ) return RicfForwarding::errorResponse( view.error(), commandName );
|
|
|
|
|
views.push_back( view.value() );
|
2019-05-23 13:59:19 +02:00
|
|
|
}
|
|
|
|
|
|
2026-09-16 15:11:15 +02:00
|
|
|
for ( Rim3dView* view : views )
|
2017-07-27 10:39:59 +02:00
|
|
|
{
|
2026-09-16 15:11:15 +02:00
|
|
|
Rim3dView_setTimeStep method( view );
|
|
|
|
|
method.setTimeStep( m_timeStepIndex() );
|
|
|
|
|
|
|
|
|
|
auto result = method.execute();
|
|
|
|
|
if ( !result ) return RicfForwarding::errorResponse( result.error(), commandName );
|
2017-07-27 10:39:59 +02:00
|
|
|
}
|
2019-05-23 13:59:19 +02:00
|
|
|
|
2020-03-10 14:11:22 +01:00
|
|
|
return caf::PdmScriptResponse();
|
2017-07-27 10:39:59 +02:00
|
|
|
}
|