From 2a19af2321ee1aa33938f47a3140e704839f4b5e Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 12 Aug 2026 15:49:16 +0200 Subject: [PATCH] #12720 Histogram: Accept summary vector drag'n'drop on histogram multi plot Add a virtual RimMultiPlot::handleDroppedObjects so RiuMultiPlotBook routes drop events to any multi plot type instead of only RimSummaryMultiPlot. Implement the handler in RimHistogramMultiPlot: each dropped ensemble summary vector, ensemble parameter or file set ensemble creates its own new histogram subplot, following the behavior of the summary multi plot. Extract RimHistogramPlot::isDroppableObject so unsupported dropped objects do not create empty subplots. --- .../Histogram/RimHistogramMultiPlot.cpp | 16 ++++++++++++++ .../Histogram/RimHistogramMultiPlot.h | 2 ++ .../Histogram/RimHistogramPlot.cpp | 22 +++++++++++++++++++ .../Histogram/RimHistogramPlot.h | 5 +++-- .../ProjectDataModel/RimMultiPlot.cpp | 7 ++++++ .../ProjectDataModel/RimMultiPlot.h | 2 ++ .../Summary/RimSummaryMultiPlot.h | 2 +- .../UserInterface/RiuMultiPlotBook.cpp | 5 ++--- 8 files changed, 55 insertions(+), 6 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/Histogram/RimHistogramMultiPlot.cpp b/ApplicationLibCode/ProjectDataModel/Histogram/RimHistogramMultiPlot.cpp index 16974b586c..497162507e 100644 --- a/ApplicationLibCode/ProjectDataModel/Histogram/RimHistogramMultiPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Histogram/RimHistogramMultiPlot.cpp @@ -21,6 +21,8 @@ #include "RiaNumericalTools.h" #include "RiaPlotDefines.h" +#include "RicHistogramPlotTools.h" + #include "RimEnsembleCurveSet.h" #include "RimHistogramPlot.h" #include "RimMainPlotCollection.h" @@ -212,6 +214,20 @@ void RimHistogramMultiPlot::updatePlotTitles() if ( !m_viewer.isNull() ) m_viewer->scheduleTitleUpdate(); } +//-------------------------------------------------------------------------------------------------- +/// Create a new subplot for each dropped object, following the behavior of the summary multi plot +//-------------------------------------------------------------------------------------------------- +void RimHistogramMultiPlot::handleDroppedObjects( const std::vector& objects ) +{ + for ( auto obj : objects ) + { + if ( !RimHistogramPlot::isDroppableObject( obj ) ) continue; + + auto* plot = RicHistogramPlotTools::addNewHistogramPlot( this ); + plot->handleDroppedObjects( { obj } ); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Histogram/RimHistogramMultiPlot.h b/ApplicationLibCode/ProjectDataModel/Histogram/RimHistogramMultiPlot.h index 5e7966a06f..685341a901 100644 --- a/ApplicationLibCode/ProjectDataModel/Histogram/RimHistogramMultiPlot.h +++ b/ApplicationLibCode/ProjectDataModel/Histogram/RimHistogramMultiPlot.h @@ -55,6 +55,8 @@ public: void updateAfterPlotRemove() override; void updatePlotTitles() override; + void handleDroppedObjects( const std::vector& objects ) override; + void syncAxisRanges(); std::vector histogramPlots() const; diff --git a/ApplicationLibCode/ProjectDataModel/Histogram/RimHistogramPlot.cpp b/ApplicationLibCode/ProjectDataModel/Histogram/RimHistogramPlot.cpp index d0f0a1c43e..4ad5d4fcf1 100644 --- a/ApplicationLibCode/ProjectDataModel/Histogram/RimHistogramPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Histogram/RimHistogramPlot.cpp @@ -1334,6 +1334,26 @@ RimHistogramPlot::GraphType RimHistogramPlot::graphType() const return m_graphType(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimHistogramPlot::isDroppableObject( caf::PdmObjectHandle* object ) +{ + if ( dynamic_cast( object ) ) return true; + + if ( auto parameter = dynamic_cast( object ) ) + { + return RiaSummaryTools::ensembleById( parameter->ensembleId() ) != nullptr; + } + + if ( auto address = dynamic_cast( object ) ) + { + return address->isEnsemble() && RiaSummaryTools::ensembleById( address->ensembleId() ) != nullptr; + } + + return false; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1341,6 +1361,8 @@ void RimHistogramPlot::handleDroppedObjects( const std::vector( obj ) ) { RicHistogramPlotTools::appendEnsembleToHistogram( this, fileSet ); diff --git a/ApplicationLibCode/ProjectDataModel/Histogram/RimHistogramPlot.h b/ApplicationLibCode/ProjectDataModel/Histogram/RimHistogramPlot.h index 637c02496c..ccd086d76b 100644 --- a/ApplicationLibCode/ProjectDataModel/Histogram/RimHistogramPlot.h +++ b/ApplicationLibCode/ProjectDataModel/Histogram/RimHistogramPlot.h @@ -146,6 +146,9 @@ public: std::vector histogramCurves() const; + static bool isDroppableObject( caf::PdmObjectHandle* object ); + void handleDroppedObjects( const std::vector& objects ) override; + public: // RimViewWindow overrides void deleteViewWidget() override; @@ -177,8 +180,6 @@ protected: void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void onLoadDataAndUpdate() override; - void handleDroppedObjects( const std::vector& objects ) override; - void initAfterRead() override; private slots: diff --git a/ApplicationLibCode/ProjectDataModel/RimMultiPlot.cpp b/ApplicationLibCode/ProjectDataModel/RimMultiPlot.cpp index cf9e00872a..c8f5864d0b 100644 --- a/ApplicationLibCode/ProjectDataModel/RimMultiPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimMultiPlot.cpp @@ -245,6 +245,13 @@ void RimMultiPlot::updateAfterPlotRemove() onPlotAdditionOrRemoval(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimMultiPlot::handleDroppedObjects( const std::vector& objects ) +{ +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimMultiPlot.h b/ApplicationLibCode/ProjectDataModel/RimMultiPlot.h index d8fb7aec55..d795e7f689 100644 --- a/ApplicationLibCode/ProjectDataModel/RimMultiPlot.h +++ b/ApplicationLibCode/ProjectDataModel/RimMultiPlot.h @@ -74,6 +74,8 @@ public: virtual void removePlotNoUpdate( RimPlot* plot ); virtual void updateAfterPlotRemove(); + virtual void handleDroppedObjects( const std::vector& objects ); + void deleteAllPlots() override; void updatePlots(); virtual void updatePlotTitles(); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.h index 003a464ef1..9ac468526a 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.h @@ -81,7 +81,7 @@ public: void syncAxisRanges(); void syncTimeAxisRanges( RimSummaryPlot* sourceSummaryPlot ); - void handleDroppedObjects( const std::vector& objects ); + void handleDroppedObjects( const std::vector& objects ) override; void summaryPlotItemInfos( QList* optionInfos ) const; diff --git a/ApplicationLibCode/UserInterface/RiuMultiPlotBook.cpp b/ApplicationLibCode/UserInterface/RiuMultiPlotBook.cpp index f5bb374518..804b5911ad 100644 --- a/ApplicationLibCode/UserInterface/RiuMultiPlotBook.cpp +++ b/ApplicationLibCode/UserInterface/RiuMultiPlotBook.cpp @@ -769,10 +769,9 @@ void RiuMultiPlotBook::dropEvent( QDropEvent* event ) if ( RiuDragDrop::handleGenericDropEvent( event, objects ) ) { - RimSummaryMultiPlot* multiPlot = dynamic_cast( m_plotDefinition.p() ); - if ( multiPlot ) + if ( m_plotDefinition.notNull() ) { - multiPlot->handleDroppedObjects( objects ); + m_plotDefinition->handleDroppedObjects( objects ); } } }