From f2fad7a975b38f348083fa150ff87cef667612c0 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 25 Oct 2019 13:15:02 +0200 Subject: [PATCH] #4926 Summary Templates : Set curve as selected object when case is imported --- .../Commands/RicImportSummaryCasesFeature.cpp | 18 ++++++++---- .../RicSummaryPlotFeatureImpl.cpp | 28 +++++++++++++------ .../RicSummaryPlotFeatureImpl.h | 7 ++++- 3 files changed, 39 insertions(+), 14 deletions(-) diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp index c015a25d42..0cef7094f1 100644 --- a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp @@ -41,6 +41,7 @@ #include "RiuMainWindow.h" #include "RiuPlotMainWindow.h" +#include "RiuPlotMainWindowTools.h" #include "SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.h" #include "SummaryPlotCommands/RicNewSummaryPlotFeature.h" @@ -84,7 +85,12 @@ void RicImportSummaryCasesFeature::onActionTriggered( bool isChecked ) addSummaryCases( cases ); if ( !cases.empty() ) { - RicSummaryPlotFeatureImpl::createDefaultSummaryPlot( cases.front() ); + auto objectToSelect = RicSummaryPlotFeatureImpl::createDefaultSummaryPlot( cases.front() ); + if ( objectToSelect ) + { + RiuPlotMainWindowTools::setExpanded( objectToSelect ); + RiuPlotMainWindowTools::selectAsCurrentItem( objectToSelect ); + } } addCasesToGroupIfRelevant( cases ); @@ -95,8 +101,6 @@ void RicImportSummaryCasesFeature::onActionTriggered( bool isChecked ) RiuPlotMainWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); if ( mainPlotWindow && !cases.empty() ) { - mainPlotWindow->selectAsCurrentItem( cases.back() ); - mainPlotWindow->updateSummaryPlotToolBar(); } @@ -134,13 +138,17 @@ bool RicImportSummaryCasesFeature::createAndAddSummaryCasesFromFiles( const QStr addSummaryCases( *cases ); if ( !cases->empty() && doCreateDefaultPlot ) { - RicSummaryPlotFeatureImpl::createDefaultSummaryPlot( cases->back() ); + auto objectToSelect = RicSummaryPlotFeatureImpl::createDefaultSummaryPlot( cases->back() ); + if ( objectToSelect ) + { + RiuPlotMainWindowTools::setExpanded( objectToSelect ); + RiuPlotMainWindowTools::selectAsCurrentItem( objectToSelect ); + } } RiuPlotMainWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); if ( mainPlotWindow && !cases->empty() ) { - mainPlotWindow->selectAsCurrentItem( cases->back() ); mainPlotWindow->updateSummaryPlotToolBar(); // Close main window if there are no eclipse cases imported diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryPlotFeatureImpl.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryPlotFeatureImpl.cpp index fe6d3e9277..c18c93a936 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryPlotFeatureImpl.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryPlotFeatureImpl.cpp @@ -131,7 +131,12 @@ void RicSummaryPlotFeatureImpl::ensureAtLeastOnePlot( RimSummaryPlotCollection* { if ( summaryPlotCollection->summaryPlots.empty() ) { - createDefaultSummaryPlot( summaryCase ); + auto objectToSelect = createDefaultSummaryPlot( summaryCase ); + if ( objectToSelect ) + { + RiuPlotMainWindowTools::setExpanded( objectToSelect ); + RiuPlotMainWindowTools::selectAsCurrentItem( objectToSelect ); + } } } } @@ -139,11 +144,13 @@ void RicSummaryPlotFeatureImpl::ensureAtLeastOnePlot( RimSummaryPlotCollection* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicSummaryPlotFeatureImpl::createDefaultSummaryPlot( RimSummaryCase* summaryCase ) +caf::PdmObject* RicSummaryPlotFeatureImpl::createDefaultSummaryPlot( RimSummaryCase* summaryCase ) { RimSummaryPlotCollection* summaryPlotCollection = RiaApplication::instance()->project()->mainPlotCollection->summaryPlotCollection(); + caf::PdmObject* itemToSelect = nullptr; + if ( summaryPlotCollection && summaryCase && !RiaApplication::instance()->preferences()->defaultSummaryCurvesTextFilter().isEmpty() ) { @@ -156,12 +163,17 @@ void RicSummaryPlotFeatureImpl::createDefaultSummaryPlot( RimSummaryCase* summar summaryPlotCollection->updateConnectedEditors(); - caf::PdmObject* itemToSelect = plot; - if ( curves.size() ) itemToSelect = curves[0]; - - RiuPlotMainWindowTools::setExpanded( itemToSelect ); - RiuPlotMainWindowTools::selectAsCurrentItem( itemToSelect ); + if ( curves.size() ) + { + itemToSelect = curves[0]; + } + else + { + itemToSelect = plot; + } } + + return itemToSelect; } RimSummaryCurve* createHistoryCurve( const RifEclipseSummaryAddress& addr, RimSummaryCase* summaryCasesToUse ) @@ -275,7 +287,7 @@ void RicSummaryPlotFeatureImpl::createSummaryPlotsFromArgumentLine( const QStrin QStringList gridFileNames; QString ensembleColoringParameter; - std::set validOptions = {"-help", "-h", "-nl", "-s", "-n", "-e", "-c", "-cl"}; + std::set validOptions = { "-help", "-h", "-nl", "-s", "-n", "-e", "-c", "-cl" }; for ( int optionIdx = 0; optionIdx < arguments.size(); ++optionIdx ) { diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryPlotFeatureImpl.h b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryPlotFeatureImpl.h index de1c35630c..a2e740fad5 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryPlotFeatureImpl.h +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryPlotFeatureImpl.h @@ -22,6 +22,11 @@ #include #include +namespace caf +{ +class PdmObject; +} + class RimSummaryCurve; class RimSummaryPlot; class RimSummaryCase; @@ -35,7 +40,7 @@ public: static RimSummaryCurve* addDefaultCurveToPlot( RimSummaryPlot* plot, RimSummaryCase* summaryCase ); static std::vector addDefaultCurvesToPlot( RimSummaryPlot* plot, RimSummaryCase* summaryCase ); static void ensureAtLeastOnePlot( RimSummaryPlotCollection* summaryPlotCollection, RimSummaryCase* summaryCase ); - static void createDefaultSummaryPlot( RimSummaryCase* summaryCase ); + static caf::PdmObject* createDefaultSummaryPlot( RimSummaryCase* summaryCase ); static void createSummaryPlotsFromArgumentLine( const QStringList& arguments );