2019-08-23 11:25:00 +02:00
|
|
|
#include "RicfCloneView.h"
|
|
|
|
|
|
2026-09-16 15:08:37 +02:00
|
|
|
#include "RicfCommandForwarding.h"
|
2019-08-23 11:25:00 +02:00
|
|
|
#include "RicfCreateView.h"
|
|
|
|
|
|
|
|
|
|
#include "Rim3dView.h"
|
2026-09-16 15:08:37 +02:00
|
|
|
#include "RimcGridView.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( RicfCloneView, "cloneView" );
|
2019-08-23 11:25:00 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RicfCloneView::RicfCloneView()
|
|
|
|
|
{
|
2021-11-14 14:15:12 +01:00
|
|
|
CAF_PDM_InitScriptableField( &m_viewId, "viewId", -1, "View Id" );
|
2019-08-23 11:25:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-03-10 14:11:22 +01:00
|
|
|
caf::PdmScriptResponse RicfCloneView::execute()
|
2019-08-23 11:25:00 +02:00
|
|
|
{
|
2026-09-16 15:08:37 +02:00
|
|
|
const QString commandName = classKeyword();
|
|
|
|
|
|
|
|
|
|
auto view = RicfForwarding::findView( m_viewId() );
|
|
|
|
|
if ( !view ) return RicfForwarding::errorResponse( view.error(), commandName );
|
2019-08-23 11:25:00 +02:00
|
|
|
|
2026-09-16 15:08:37 +02:00
|
|
|
Rim3dView_clone method( view.value() );
|
2019-08-23 11:25:00 +02:00
|
|
|
|
2026-09-16 15:08:37 +02:00
|
|
|
auto result = method.execute();
|
|
|
|
|
if ( !result ) return RicfForwarding::errorResponse( result.error(), commandName );
|
2019-08-23 11:25:00 +02:00
|
|
|
|
2026-09-16 15:08:37 +02:00
|
|
|
auto* newView = dynamic_cast<Rim3dView*>( result.value() );
|
|
|
|
|
if ( !newView ) return RicfForwarding::errorResponse( "Cloned object is not a view", commandName );
|
2019-08-23 11:25:00 +02:00
|
|
|
|
2026-09-16 15:08:37 +02:00
|
|
|
caf::PdmScriptResponse response;
|
|
|
|
|
response.setResult( new RicfCreateViewResult( newView->id() ) );
|
|
|
|
|
return response;
|
2019-08-23 11:25:00 +02:00
|
|
|
}
|