From 6dfd99440301e50cbfcc7bd2ee1324c70a44cecc Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Mon, 10 Feb 2020 13:10:25 +0100 Subject: [PATCH] #5498 Disallow pasting WBS curves into a different plot. --- .../RicPasteWellLogCurveFeature.cpp | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/ApplicationCode/Commands/WellLogCommands/RicPasteWellLogCurveFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicPasteWellLogCurveFeature.cpp index eade406d3b..019861b291 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicPasteWellLogCurveFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicPasteWellLogCurveFeature.cpp @@ -21,6 +21,7 @@ #include "OperationsUsingObjReferences/RicPasteFeatureImpl.h" +#include "RimWellBoreStabilityPlot.h" #include "RimWellLogCurve.h" #include "RimWellLogExtractionCurve.h" #include "RimWellLogFileCurve.h" @@ -55,6 +56,20 @@ bool RicPasteWellLogCurveFeature::isCommandEnabled() return false; } + RimWellBoreStabilityPlot* wbsPlotToPasteInto = nullptr; + wellLogTrack->firstAncestorOrThisOfType( wbsPlotToPasteInto ); + + std::vector> sourceObjects = RicPasteWellLogCurveFeature::curves(); + + for ( size_t i = 0; i < sourceObjects.size(); i++ ) + { + RimWellBoreStabilityPlot* originalWbsPlot = nullptr; + sourceObjects[i]->firstAncestorOrThisOfType( originalWbsPlot ); + if ( originalWbsPlot && originalWbsPlot != wbsPlotToPasteInto ) + { + return false; + } + } return RicPasteWellLogCurveFeature::curves().size() > 0; } @@ -76,10 +91,20 @@ void RicPasteWellLogCurveFeature::onActionTriggered( bool isChecked ) return; } + RimWellBoreStabilityPlot* wbsPlotToPasteInto = nullptr; + wellLogTrack->firstAncestorOrThisOfType( wbsPlotToPasteInto ); + std::vector> sourceObjects = RicPasteWellLogCurveFeature::curves(); for ( size_t i = 0; i < sourceObjects.size(); i++ ) { + RimWellBoreStabilityPlot* originalWbsPlot = nullptr; + sourceObjects[i]->firstAncestorOrThisOfType( originalWbsPlot ); + if ( originalWbsPlot && originalWbsPlot != wbsPlotToPasteInto ) + { + continue; + } + RimWellLogFileCurve* fileCurve = dynamic_cast( sourceObjects[i].p() ); if ( fileCurve ) {