2019-08-23 11:25:00 +02:00
|
|
|
#include "RicfCreateView.h"
|
|
|
|
|
|
2026-09-16 15:06:10 +02:00
|
|
|
#include "RicfCommandForwarding.h"
|
2019-08-23 11:25:00 +02:00
|
|
|
|
|
|
|
|
#include "Rim3dView.h"
|
2026-09-16 15:06:10 +02:00
|
|
|
#include "RimCase.h"
|
|
|
|
|
#include "RimcCase.h"
|
2019-08-23 11:25:00 +02:00
|
|
|
|
2020-08-21 11:13:07 +02:00
|
|
|
#include "cafPdmFieldScriptingCapability.h"
|
2019-08-23 11:25:00 +02:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
CAF_PDM_SOURCE_INIT( RicfCreateViewResult, "createViewResult" );
|
2019-08-23 11:25:00 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
RicfCreateViewResult::RicfCreateViewResult( int viewId /*= -1*/ )
|
2019-08-23 11:25:00 +02:00
|
|
|
{
|
2021-11-14 14:15:12 +01:00
|
|
|
CAF_PDM_InitObject( "view_result" );
|
|
|
|
|
CAF_PDM_InitField( &this->viewId, "viewId", viewId, "" );
|
2019-08-23 11:25:00 +02:00
|
|
|
}
|
|
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
CAF_PDM_SOURCE_INIT( RicfCreateView, "createView" );
|
2019-08-23 11:25:00 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RicfCreateView::RicfCreateView()
|
|
|
|
|
{
|
2021-11-14 14:15:12 +01:00
|
|
|
CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "Case Id" );
|
2019-08-23 11:25:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-03-10 14:11:22 +01:00
|
|
|
caf::PdmScriptResponse RicfCreateView::execute()
|
2019-08-23 11:25:00 +02:00
|
|
|
{
|
2026-09-16 15:06:10 +02:00
|
|
|
const QString commandName = classKeyword();
|
|
|
|
|
|
|
|
|
|
auto rimCase = RicfForwarding::findCase( m_caseId() );
|
|
|
|
|
if ( !rimCase ) return RicfForwarding::errorResponse( rimCase.error(), commandName );
|
|
|
|
|
|
|
|
|
|
RimCase_createView method( rimCase.value() );
|
|
|
|
|
|
|
|
|
|
auto result = method.execute();
|
|
|
|
|
if ( !result ) return RicfForwarding::errorResponse( result.error(), commandName );
|
2019-08-23 11:25:00 +02:00
|
|
|
|
2026-09-16 15:06:10 +02:00
|
|
|
auto* view = dynamic_cast<Rim3dView*>( result.value() );
|
|
|
|
|
if ( !view ) return RicfForwarding::errorResponse( "Created object is not a view", commandName );
|
2019-08-23 11:25:00 +02:00
|
|
|
|
2026-09-16 15:06:10 +02:00
|
|
|
caf::PdmScriptResponse response;
|
|
|
|
|
response.setResult( new RicfCreateViewResult( view->id() ) );
|
|
|
|
|
return response;
|
2019-08-23 11:25:00 +02:00
|
|
|
}
|