Files
ResInsight/ApplicationLibCode/CommandFileInterface/RicfCreateGridCaseGroup.cpp
T

70 lines
2.9 KiB
C++
Raw Normal View History

2019-07-18 10:53:59 +02:00
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- 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 "RicfCreateGridCaseGroup.h"
#include "RicfCommandForwarding.h"
2019-07-18 10:53:59 +02:00
#include "RimIdenticalGridCaseGroup.h"
#include "RimProject.h"
#include "RimcProject.h"
2019-07-18 10:53:59 +02:00
2020-08-21 11:13:07 +02:00
#include "cafPdmFieldScriptingCapability.h"
2020-03-10 14:11:22 +01:00
CAF_PDM_SOURCE_INIT( RicfCreateGridCaseGroupResult, "createGridCaseGroupResult" );
2019-07-18 10:53:59 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2023-02-26 10:48:40 +01:00
RicfCreateGridCaseGroupResult::RicfCreateGridCaseGroupResult( int caseGroupId /*= -1*/, const QString& caseGroupName /*= ""*/ )
2019-07-18 10:53:59 +02:00
{
CAF_PDM_InitObject( "case_group_result" );
CAF_PDM_InitField( &this->caseGroupId, "groupId", caseGroupId, "" );
CAF_PDM_InitField( &this->caseGroupName, "groupName", caseGroupName, "" );
2019-07-18 10:53:59 +02:00
}
CAF_PDM_SOURCE_INIT( RicfCreateGridCaseGroup, "createGridCaseGroup" );
2019-07-18 10:53:59 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfCreateGridCaseGroup::RicfCreateGridCaseGroup()
{
CAF_PDM_InitScriptableFieldNoDefault( &m_casePaths, "casePaths", "List of Paths to Case Files" );
2019-07-18 10:53:59 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2020-03-10 14:11:22 +01:00
caf::PdmScriptResponse RicfCreateGridCaseGroup::execute()
2019-07-18 10:53:59 +02:00
{
const QString commandName = classKeyword();
RimProject_createGridCaseGroup method( RimProject::current() );
method.setCasePaths( m_casePaths() );
auto result = method.execute();
if ( !result ) return RicfForwarding::errorResponse( result.error(), commandName );
2019-07-18 10:53:59 +02:00
auto* caseGroup = dynamic_cast<RimIdenticalGridCaseGroup*>( result.value() );
if ( !caseGroup ) return RicfForwarding::errorResponse( "Created object is not a grid case group", commandName );
2019-07-18 10:53:59 +02:00
caf::PdmScriptResponse response;
response.setResult( new RicfCreateGridCaseGroupResult( caseGroup->groupId(), caseGroup->name() ) );
return response;
2019-07-18 10:53:59 +02:00
}