mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
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:
@@ -121,8 +121,7 @@ void RimUserDefinedPolylinesAnnotation::appendTarget( const cvf::Vec3d& defaultP
|
||||
}
|
||||
else
|
||||
{
|
||||
target = dynamic_cast<RimPolylineTarget*>(
|
||||
targets.back()->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
|
||||
target = targets.back()->copyObject<RimPolylineTarget>();
|
||||
}
|
||||
|
||||
if ( target )
|
||||
|
||||
@@ -221,11 +221,9 @@ void RimFractureTemplateCollection::createAndAssignTemplateCopyForNonMatchingUni
|
||||
{
|
||||
if ( !templateWithMatchingUnit )
|
||||
{
|
||||
templateWithMatchingUnit = dynamic_cast<RimFractureTemplate*>(
|
||||
fractureTemplate->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
|
||||
|
||||
auto currentUnit = fractureTemplate->fractureTemplateUnit();
|
||||
auto neededUnit = RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN;
|
||||
templateWithMatchingUnit = fractureTemplate->copyObject<RimFractureTemplate>();
|
||||
auto currentUnit = fractureTemplate->fractureTemplateUnit();
|
||||
auto neededUnit = RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN;
|
||||
if ( currentUnit == RiaDefines::EclipseUnitSystem::UNITS_METRIC )
|
||||
{
|
||||
neededUnit = RiaDefines::EclipseUnitSystem::UNITS_FIELD;
|
||||
|
||||
@@ -247,8 +247,7 @@ RimGeoMechView* RimGeoMechCase::createAndAddReservoirView()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGeoMechView* RimGeoMechCase::createCopyAndAddView( const RimGeoMechView* sourceView )
|
||||
{
|
||||
RimGeoMechView* rimGeoMechView =
|
||||
dynamic_cast<RimGeoMechView*>( sourceView->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
|
||||
auto rimGeoMechView = sourceView->copyObject<RimGeoMechView>();
|
||||
CVF_ASSERT( rimGeoMechView );
|
||||
|
||||
rimGeoMechView->setGeoMechCase( this );
|
||||
@@ -268,8 +267,7 @@ RimGeoMechCase* RimGeoMechCase::createCopy( const QString& newInputFileName )
|
||||
{
|
||||
RimProject* project = RimProject::current();
|
||||
|
||||
RimGeoMechCase* copycase =
|
||||
dynamic_cast<RimGeoMechCase*>( xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
|
||||
auto copycase = copyObject<RimGeoMechCase>();
|
||||
CVF_ASSERT( copycase );
|
||||
|
||||
QFileInfo filenameInfo( newInputFileName );
|
||||
|
||||
@@ -329,8 +329,7 @@ RimEclipseView* RimEclipseCase::createCopyAndAddView( const RimEclipseView* sour
|
||||
{
|
||||
CVF_ASSERT( sourceView );
|
||||
|
||||
RimEclipseView* rimEclipseView =
|
||||
dynamic_cast<RimEclipseView*>( sourceView->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
|
||||
auto rimEclipseView = sourceView->copyObject<RimEclipseView>();
|
||||
CVF_ASSERT( rimEclipseView );
|
||||
rimEclipseView->setEclipseCase( this );
|
||||
|
||||
|
||||
@@ -65,8 +65,7 @@ RimUserDefinedCalculation* RimUserDefinedCalculationCollection::addCalculation(
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimUserDefinedCalculation* RimUserDefinedCalculationCollection::addCalculationCopy( const RimUserDefinedCalculation* sourceCalculation )
|
||||
{
|
||||
RimUserDefinedCalculation* calcCopy = dynamic_cast<RimUserDefinedCalculation*>(
|
||||
sourceCalculation->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
|
||||
auto calcCopy = sourceCalculation->copyObject<RimUserDefinedCalculation>();
|
||||
CVF_ASSERT( calcCopy );
|
||||
|
||||
std::set<QString> calcNames;
|
||||
|
||||
@@ -2282,8 +2282,7 @@ void RimEnsembleCurveSet::updateStatisticsCurves()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEnsembleCurveSet* RimEnsembleCurveSet::clone() const
|
||||
{
|
||||
RimEnsembleCurveSet* copy =
|
||||
dynamic_cast<RimEnsembleCurveSet*>( xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
|
||||
auto copy = copyObject<RimEnsembleCurveSet>();
|
||||
copy->setSummaryCaseCollection( m_yValuesSummaryCaseCollection() );
|
||||
|
||||
// Update summary case references
|
||||
|
||||
@@ -159,8 +159,7 @@ void RimSummaryMultiPlotCollection::duplicatePlot( RimSummaryMultiPlot* plotToDu
|
||||
{
|
||||
if ( !plotToDuplicate ) return;
|
||||
|
||||
auto plotCopy = dynamic_cast<RimSummaryMultiPlot*>( plotToDuplicate->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
|
||||
|
||||
auto plotCopy = plotToDuplicate->copyObject<RimSummaryMultiPlot>();
|
||||
addSummaryMultiPlot( plotCopy );
|
||||
|
||||
plotCopy->resolveReferencesRecursively();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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() )
|
||||
|
||||
@@ -427,8 +427,7 @@ RimWellPathTarget* RimWellPathGeometryDef::appendTarget()
|
||||
}
|
||||
else
|
||||
{
|
||||
wellPathTarget = dynamic_cast<RimWellPathTarget*>(
|
||||
targets.back()->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
|
||||
wellPathTarget = targets.back()->copyObject<RimWellPathTarget>();
|
||||
}
|
||||
|
||||
if ( wellPathTarget )
|
||||
|
||||
Reference in New Issue
Block a user