From e9b95ae7407e44249c3e53bac635b6501e98e44e Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 21 Sep 2023 15:06:23 +0200 Subject: [PATCH] Convert cross plots into summary plots --- .../RimMainPlotCollection.cpp | 49 ++++++++++++++++--- .../ProjectDataModel/RimProject.cpp | 5 -- 2 files changed, 43 insertions(+), 11 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/RimMainPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimMainPlotCollection.cpp index f66ceac04a..da6602489f 100644 --- a/ApplicationLibCode/ProjectDataModel/RimMainPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimMainPlotCollection.cpp @@ -20,6 +20,7 @@ #include "RimMainPlotCollection.h" #include "RiaPlotCollectionScheduler.h" +#include "RiaSummaryDefines.h" #include "PlotBuilderCommands/RicSummaryPlotBuilder.h" @@ -42,6 +43,8 @@ #include "RimStimPlanModelPlotCollection.h" #include "RimSummaryAddress.h" #include "RimSummaryCrossPlotCollection.h" +#include "RimSummaryCurve.h" +#include "RimSummaryDataSourceStepping.h" #include "RimSummaryMultiPlot.h" #include "RimSummaryMultiPlotCollection.h" #include "RimSummaryPlotCollection.h" @@ -176,17 +179,51 @@ RimMainPlotCollection* RimMainPlotCollection::current() //-------------------------------------------------------------------------------------------------- void RimMainPlotCollection::initAfterRead() { - std::vector plotsToMove; - for ( auto singlePlot : m_summaryPlotCollection_OBSOLETE()->plots() ) { - plotsToMove.push_back( singlePlot ); + std::vector plotsToMove; + for ( auto singlePlot : m_summaryPlotCollection_OBSOLETE()->plots() ) + { + plotsToMove.push_back( singlePlot ); + } + + for ( auto singlePlot : plotsToMove ) + { + m_summaryPlotCollection_OBSOLETE()->removePlot( singlePlot ); + + RicSummaryPlotBuilder::createAndAppendSingleSummaryMultiPlotNoAutoSettings( singlePlot ); + } } - for ( auto singlePlot : plotsToMove ) + // Move cross plots into summary plot collection + auto crossPlots = m_summaryCrossPlotCollection_OBSOLETE->plots(); + if ( !crossPlots.empty() ) { - m_summaryPlotCollection_OBSOLETE()->removePlot( singlePlot ); + auto* summaryMultiPlot = new RimSummaryMultiPlot; + summaryMultiPlot->setMultiPlotTitle( QString( "Multi Plot %1" ).arg( m_summaryMultiPlotCollection->multiPlots().size() + 1 ) ); + summaryMultiPlot->setAsPlotMdiWindow(); + m_summaryMultiPlotCollection->addSummaryMultiPlot( summaryMultiPlot ); + + for ( auto crossPlot : crossPlots ) + { + m_summaryCrossPlotCollection_OBSOLETE->removePlot( crossPlot ); + summaryMultiPlot->addPlot( crossPlot ); - RicSummaryPlotBuilder::createAndAppendSingleSummaryMultiPlotNoAutoSettings( singlePlot ); + // We want to convert RimSummaryCrossPlot into a RimSummaryPlot. The cross plot is derived from RimSummaryPlot, but we need to + // create a new RimSummaryPlot to be able to store the PDM object as a RimSummaryPlot instead of RimSummaryCrossPlot + auto summaryPlot = new RimSummaryPlot; + summaryMultiPlot->addPlot( summaryPlot ); + + for ( auto curve : crossPlot->allCurves( RimSummaryDataSourceStepping::Axis::Y_AXIS ) ) + { + crossPlot->removeCurve( curve ); + + if ( curve->summaryCaseX() != nullptr ) curve->setAxisTypeX( RiaDefines::HorizontalAxisType::SUMMARY_VECTOR ); + + summaryPlot->insertCurve( curve, size_t( 999 ) ); + } + + delete crossPlot; + } } } diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.cpp b/ApplicationLibCode/ProjectDataModel/RimProject.cpp index b03393407c..9ad3c7c769 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimProject.cpp @@ -1422,11 +1422,6 @@ void RimProject::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, Q uiTreeOrdering.add( m_mainPlotCollection->correlationPlotCollection() ); } - if ( m_mainPlotCollection->summaryCrossPlotCollection() ) - { - uiTreeOrdering.add( m_mainPlotCollection->summaryCrossPlotCollection() ); - } - if ( m_mainPlotCollection->summaryTableCollection() ) { uiTreeOrdering.add( m_mainPlotCollection->summaryTableCollection() );