Add copyObject to PdmObjectHandle

New syntax to copy an object

    auto curveCopy = curve->copyObject<RimSummaryCurve>();

Previous deprecated syntax

    RimColorLegend* customLegend = dynamic_cast<RimColorLegend*>(
            standardLegend->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
This commit is contained in:
Magne Sjaastad
2024-06-14 17:18:28 +02:00
committed by GitHub
parent 7efefbb93a
commit a0ebb6e496
46 changed files with 126 additions and 131 deletions

View File

@@ -86,9 +86,7 @@ bool RimEnsembleStatisticsSurface::onLoadData()
//--------------------------------------------------------------------------------------------------
RimSurface* RimEnsembleStatisticsSurface::createCopy()
{
auto* newSurface =
dynamic_cast<RimEnsembleStatisticsSurface*>( xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
auto newSurface = copyObject<RimEnsembleStatisticsSurface>();
if ( !newSurface->onLoadData() )
{
delete newSurface;

View File

@@ -81,9 +81,7 @@ bool RimFileSurface::onLoadData()
//--------------------------------------------------------------------------------------------------
RimSurface* RimFileSurface::createCopy()
{
RimFileSurface* newSurface =
dynamic_cast<RimFileSurface*>( xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
auto newSurface = copyObject<RimFileSurface>();
if ( !newSurface->onLoadData() )
{
delete newSurface;

View File

@@ -89,7 +89,7 @@ bool RimGridCaseSurface::onLoadData()
//--------------------------------------------------------------------------------------------------
RimSurface* RimGridCaseSurface::createCopy()
{
auto* newSurface = dynamic_cast<RimGridCaseSurface*>( xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
auto* newSurface = copyObject<RimGridCaseSurface>();
newSurface->setCase( m_case.value() ); // TODO: case seems to get lost in the xml copy, investigate later
if ( !newSurface->onLoadData() )