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

@@ -78,10 +78,8 @@ void RicPasteIntersectionsFeature::onActionTriggered( bool isChecked )
for ( size_t i = 0; i < intersectionObjects.size(); i++ )
{
RimExtrudedCurveIntersection* intersection = dynamic_cast<RimExtrudedCurveIntersection*>(
intersectionObjects[i]->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
QString nameOfCopy = QString( "Copy of " ) + intersection->name();
auto intersection = intersectionObjects[i]->copyObject<RimExtrudedCurveIntersection>();
QString nameOfCopy = QString( "Copy of " ) + intersection->name();
intersection->setName( nameOfCopy );
if ( i == intersectionObjects.size() - 1 )
@@ -99,10 +97,8 @@ void RicPasteIntersectionsFeature::onActionTriggered( bool isChecked )
for ( size_t i = 0; i < intersectionBoxObjects.size(); i++ )
{
RimBoxIntersection* intersectionBox = dynamic_cast<RimBoxIntersection*>(
intersectionBoxObjects[i]->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
QString nameOfCopy = QString( "Copy of " ) + intersectionBox->name();
RimBoxIntersection* intersectionBox = intersectionBoxObjects[i]->copyObject<RimBoxIntersection>();
QString nameOfCopy = QString( "Copy of " ) + intersectionBox->name();
intersectionBox->setName( nameOfCopy );
if ( i == intersectionBoxObjects.size() - 1 )