diff --git a/ApplicationCode/Commands/WellLogCommands/RicDeleteSubPlotFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicDeleteSubPlotFeature.cpp index 8b0218433b..c14cf0f71a 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicDeleteSubPlotFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicDeleteSubPlotFeature.cpp @@ -27,6 +27,7 @@ #include "RimMultiPlot.h" #include "RimPlotWindow.h" +#include "RimWellLogPlot.h" #include "RimWellLogTrack.h" #include "cafSelectionManager.h" @@ -50,9 +51,11 @@ bool RicDeleteSubPlotFeature::isCommandEnabled() size_t plotsSelected = 0; for ( caf::PdmObject* object : selection ) { - RimMultiPlot* multiPlot = nullptr; + RimMultiPlot* multiPlot = nullptr; + RimWellLogPlot* wellLogPlot = nullptr; object->firstAncestorOrThisOfType( multiPlot ); - if ( dynamic_cast( object ) && multiPlot ) + object->firstAncestorOrThisOfType( wellLogPlot ); + if ( dynamic_cast( object ) && ( multiPlot || wellLogPlot ) ) { plotsSelected++; } @@ -72,26 +75,34 @@ void RicDeleteSubPlotFeature::onActionTriggered( bool isChecked ) std::vector selection; caf::SelectionManager::instance()->objectsByType( &selection ); - std::set alteredPlotWindows; + std::set alteredPlotWindows; for ( RimPlot* plot : selection ) { - RimMultiPlot* plotWindow = nullptr; - plot->firstAncestorOrThisOfType( plotWindow ); - if ( plot && plotWindow ) + if ( !plot ) continue; + + RimMultiPlot* multiPlot = nullptr; + RimWellLogPlot* wellLogPlot = nullptr; + plot->firstAncestorOrThisOfType( multiPlot ); + plot->firstAncestorOrThisOfType( wellLogPlot ); + if ( multiPlot ) { - alteredPlotWindows.insert( plotWindow ); - plotWindow->removePlot( plot ); + alteredPlotWindows.insert( multiPlot ); + multiPlot->removePlot( plot ); caf::SelectionManager::instance()->removeObjectFromAllSelections( plot ); - plotWindow->updateConnectedEditors(); + multiPlot->updateConnectedEditors(); delete plot; } - } + else if ( wellLogPlot ) + { + alteredPlotWindows.insert( wellLogPlot ); + wellLogPlot->removePlot( plot ); + caf::SelectionManager::instance()->removeObjectFromAllSelections( plot ); - for ( RimMultiPlot* plotWindow : alteredPlotWindows ) - { - plotWindow->uiCapability()->updateConnectedEditors(); + wellLogPlot->updateConnectedEditors(); + delete plot; + } } }