From a1e7b64d922d92ea0701741b51b0c2604348e12a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 18 Aug 2022 03:37:51 -0700 Subject: [PATCH] Simplify RiuPlotMainWindowTools (#9211) * Janitor: Add and use onObjectAppended() * Janitor: Simplify API --- .../RicNewAnalysisPlotFeature.cpp | 4 +--- .../RicNewPlotDataFilterFeature.cpp | 3 +-- .../RicNewStimPlanModelPlotFeature.cpp | 5 +--- .../RicNewCorrelationMatrixPlotFeature.cpp | 4 +--- .../RicNewCorrelationPlotFeature.cpp | 4 +--- .../RicNewCorrelationReportPlotFeature.cpp | 4 +--- .../RicNewParameterResultCrossPlotFeature.cpp | 4 +--- ...ddStoredFlowCharacteristicsPlotFeature.cpp | 5 +--- .../RicAddStoredWellAllocationPlotFeature.cpp | 4 +--- .../RicShowFlowCharacteristicsPlotFeature.cpp | 4 +--- .../RicShowWellAllocationPlotFeature.cpp | 4 +--- .../RicCreateGridCrossPlotFeature.cpp | 4 ++-- ...icCreateSaturationPressurePlotsFeature.cpp | 3 +-- .../RicSummaryPlotBuilder.cpp | 8 +++---- ...eEnsembleFractureStatisticsPlotFeature.cpp | 3 +-- .../RicCreateEnsembleWellLogFeature.cpp | 3 +-- .../RicCreateGridStatisticsPlotFeature.cpp | 3 +-- .../Commands/RicImportSummaryCasesFeature.cpp | 4 +--- ...ewCustomObjectiveFunctionWeightFeature.cpp | 3 +-- .../Commands/RicNewVfpPlotFeature.cpp | 3 +-- .../RicNewSummaryCrossPlotCurveFeature.cpp | 4 +--- .../RicNewSummaryCrossPlotFeature.cpp | 4 +--- .../RicAddWellLogToPlotFeature.cpp | 4 +--- .../RicNewEnsembleWellLogCurveSetFeature.cpp | 4 ++-- .../WellLogCommands/RicNewPltPlotFeature.cpp | 4 +--- .../WellLogCommands/RicNewRftPlotFeature.cpp | 4 +--- .../RicNewRftSegmentWellLogPlotFeature.cpp | 3 +-- .../RicNewRftWellLogPlotFeature.cpp | 5 +--- .../RicNewWellBoreStabilityPlotFeature.cpp | 5 +--- .../RimObservedDataCollection.cpp | 3 +-- .../Summary/RimSummaryMultiPlot.cpp | 2 +- .../Summary/RimSummaryMultiPlotCollection.cpp | 2 +- .../UserInterface/RiuPlotMainWindowTools.cpp | 24 +++++++++++++++---- .../UserInterface/RiuPlotMainWindowTools.h | 12 +++++++--- 34 files changed, 66 insertions(+), 93 deletions(-) diff --git a/ApplicationLibCode/Commands/AnalysisPlotCommands/RicNewAnalysisPlotFeature.cpp b/ApplicationLibCode/Commands/AnalysisPlotCommands/RicNewAnalysisPlotFeature.cpp index 35af3e91a8..2936aab8e7 100644 --- a/ApplicationLibCode/Commands/AnalysisPlotCommands/RicNewAnalysisPlotFeature.cpp +++ b/ApplicationLibCode/Commands/AnalysisPlotCommands/RicNewAnalysisPlotFeature.cpp @@ -96,9 +96,7 @@ void RicNewAnalysisPlotFeature::onActionTriggered( bool isChecked ) if ( analysisPlotColl ) analysisPlotColl->updateConnectedEditors(); - RiuPlotMainWindowTools::setExpanded( newPlot ); - RiuPlotMainWindowTools::selectAsCurrentItem( newPlot ); - RiuPlotMainWindowTools::refreshToolbars(); + RiuPlotMainWindowTools::onObjectAppended( newPlot ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/AnalysisPlotCommands/RicNewPlotDataFilterFeature.cpp b/ApplicationLibCode/Commands/AnalysisPlotCommands/RicNewPlotDataFilterFeature.cpp index c1da4506d2..592f86a0c3 100644 --- a/ApplicationLibCode/Commands/AnalysisPlotCommands/RicNewPlotDataFilterFeature.cpp +++ b/ApplicationLibCode/Commands/AnalysisPlotCommands/RicNewPlotDataFilterFeature.cpp @@ -56,8 +56,7 @@ void RicNewPlotDataFilterFeature::onActionTriggered( bool isChecked ) analysisPlot->updateConnectedEditors(); - RiuPlotMainWindowTools::setExpanded( newFilter ); - RiuPlotMainWindowTools::selectAsCurrentItem( newFilter ); + RiuPlotMainWindowTools::onObjectAppended( newFilter ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/CompletionCommands/RicNewStimPlanModelPlotFeature.cpp b/ApplicationLibCode/Commands/CompletionCommands/RicNewStimPlanModelPlotFeature.cpp index f0eb7d6508..a446daaa2b 100644 --- a/ApplicationLibCode/Commands/CompletionCommands/RicNewStimPlanModelPlotFeature.cpp +++ b/ApplicationLibCode/Commands/CompletionCommands/RicNewStimPlanModelPlotFeature.cpp @@ -175,11 +175,8 @@ RimStimPlanModelPlot* RicNewStimPlanModelPlotFeature::createPlot( RimStimPlanMod plot->setAutoScaleDepthValuesEnabled( true ); } - RiuPlotMainWindowTools::selectAsCurrentItem( plot ); - RiuPlotMainWindowTools::refreshToolbars(); - - // Make sure the summary plot window is visible RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::onObjectAppended( plot ); plot->loadDataAndUpdate(); diff --git a/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationMatrixPlotFeature.cpp b/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationMatrixPlotFeature.cpp index b7f4fd55cd..d07e248af1 100644 --- a/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationMatrixPlotFeature.cpp +++ b/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationMatrixPlotFeature.cpp @@ -100,9 +100,7 @@ void RicNewCorrelationMatrixPlotFeature::onActionTriggered( bool isChecked ) if ( correlationPlotColl ) correlationPlotColl->updateConnectedEditors(); - RiuPlotMainWindowTools::setExpanded( newPlot ); - RiuPlotMainWindowTools::selectAsCurrentItem( newPlot ); - RiuPlotMainWindowTools::refreshToolbars(); + RiuPlotMainWindowTools::onObjectAppended( newPlot ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationPlotFeature.cpp b/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationPlotFeature.cpp index 3211e13da4..e88f2d33b9 100644 --- a/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationPlotFeature.cpp +++ b/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationPlotFeature.cpp @@ -95,9 +95,7 @@ void RicNewCorrelationPlotFeature::onActionTriggered( bool isChecked ) if ( correlationPlotColl ) correlationPlotColl->updateConnectedEditors(); - RiuPlotMainWindowTools::setExpanded( newPlot ); - RiuPlotMainWindowTools::selectAsCurrentItem( newPlot ); - RiuPlotMainWindowTools::refreshToolbars(); + RiuPlotMainWindowTools::onObjectAppended( newPlot ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationReportPlotFeature.cpp b/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationReportPlotFeature.cpp index 38612778dc..9c824d9a1e 100644 --- a/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationReportPlotFeature.cpp +++ b/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewCorrelationReportPlotFeature.cpp @@ -101,9 +101,7 @@ void RicNewCorrelationReportPlotFeature::onActionTriggered( bool isChecked ) if ( correlationPlotColl ) correlationPlotColl->updateConnectedEditors(); - RiuPlotMainWindowTools::setExpanded( newPlot ); - RiuPlotMainWindowTools::selectAsCurrentItem( newPlot ); - RiuPlotMainWindowTools::refreshToolbars(); + RiuPlotMainWindowTools::onObjectAppended( newPlot ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewParameterResultCrossPlotFeature.cpp b/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewParameterResultCrossPlotFeature.cpp index 9f5d06da5c..a0b1e13bfe 100644 --- a/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewParameterResultCrossPlotFeature.cpp +++ b/ApplicationLibCode/Commands/CorrelationPlotCommands/RicNewParameterResultCrossPlotFeature.cpp @@ -105,9 +105,7 @@ void RicNewParameterResultCrossPlotFeature::onActionTriggered( bool isChecked ) if ( correlationPlotColl ) correlationPlotColl->updateConnectedEditors(); - RiuPlotMainWindowTools::setExpanded( newPlot ); - RiuPlotMainWindowTools::selectAsCurrentItem( newPlot ); - RiuPlotMainWindowTools::refreshToolbars(); + RiuPlotMainWindowTools::onObjectAppended( newPlot ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/FlowCommands/RicAddStoredFlowCharacteristicsPlotFeature.cpp b/ApplicationLibCode/Commands/FlowCommands/RicAddStoredFlowCharacteristicsPlotFeature.cpp index 857ff4b94d..4c71357e59 100644 --- a/ApplicationLibCode/Commands/FlowCommands/RicAddStoredFlowCharacteristicsPlotFeature.cpp +++ b/ApplicationLibCode/Commands/FlowCommands/RicAddStoredFlowCharacteristicsPlotFeature.cpp @@ -81,10 +81,7 @@ void RicAddStoredFlowCharacteristicsPlotFeature::onActionTriggered( bool isCheck flowPlotColl->updateConnectedEditors(); RiuPlotMainWindowTools::showPlotMainWindow(); - - RiuPlotMainWindowTools::selectAsCurrentItem( flowCharacteristicsPlot ); - RiuPlotMainWindowTools::setExpanded( flowCharacteristicsPlot ); - RiuPlotMainWindowTools::refreshToolbars(); + RiuPlotMainWindowTools::onObjectAppended( flowCharacteristicsPlot ); } } } diff --git a/ApplicationLibCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.cpp b/ApplicationLibCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.cpp index ae6e6c2918..f1297e64e6 100644 --- a/ApplicationLibCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.cpp +++ b/ApplicationLibCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.cpp @@ -81,9 +81,7 @@ void RicAddStoredWellAllocationPlotFeature::onActionTriggered( bool isChecked ) flowPlotColl->updateConnectedEditors(); - RiuPlotMainWindowTools::selectAsCurrentItem( wellAllocationPlot ); - RiuPlotMainWindowTools::setExpanded( wellAllocationPlot ); - RiuPlotMainWindowTools::refreshToolbars(); + RiuPlotMainWindowTools::onObjectAppended( wellAllocationPlot ); } } } diff --git a/ApplicationLibCode/Commands/FlowCommands/RicShowFlowCharacteristicsPlotFeature.cpp b/ApplicationLibCode/Commands/FlowCommands/RicShowFlowCharacteristicsPlotFeature.cpp index 96ad70499e..7e2ea1e591 100644 --- a/ApplicationLibCode/Commands/FlowCommands/RicShowFlowCharacteristicsPlotFeature.cpp +++ b/ApplicationLibCode/Commands/FlowCommands/RicShowFlowCharacteristicsPlotFeature.cpp @@ -96,9 +96,7 @@ void RicShowFlowCharacteristicsPlotFeature::onActionTriggered( bool isChecked ) flowPlotColl->defaultFlowCharacteristicsPlot()->setFromFlowSolution( eclCase->defaultFlowDiagSolution() ); flowPlotColl->defaultFlowCharacteristicsPlot()->updateConnectedEditors(); - // Make sure the summary plot window is created and visible - RiuPlotMainWindowTools::selectAsCurrentItem( flowPlotColl->defaultFlowCharacteristicsPlot() ); - RiuPlotMainWindowTools::refreshToolbars(); + RiuPlotMainWindowTools::onObjectAppended( flowPlotColl->defaultFlowCharacteristicsPlot() ); } } } diff --git a/ApplicationLibCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.cpp b/ApplicationLibCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.cpp index 188bd4d740..2acbcf571f 100644 --- a/ApplicationLibCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.cpp +++ b/ApplicationLibCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.cpp @@ -111,10 +111,8 @@ void RicShowWellAllocationPlotFeature::onActionTriggered( bool isChecked ) flowPlotColl->defaultWellAllocPlot()->setFromSimulationWell( simWell ); flowPlotColl->defaultWellAllocPlot()->updateConnectedEditors(); - // Make sure the summary plot window is created and visible RiuPlotMainWindowTools::showPlotMainWindow(); - RiuPlotMainWindowTools::selectAsCurrentItem( flowPlotColl->defaultWellAllocPlot() ); - RiuPlotMainWindowTools::refreshToolbars(); + RiuPlotMainWindowTools::onObjectAppended( flowPlotColl->defaultWellAllocPlot() ); } } } diff --git a/ApplicationLibCode/Commands/GridCrossPlotCommands/RicCreateGridCrossPlotFeature.cpp b/ApplicationLibCode/Commands/GridCrossPlotCommands/RicCreateGridCrossPlotFeature.cpp index 1af2c46a51..eeed0ccaf7 100644 --- a/ApplicationLibCode/Commands/GridCrossPlotCommands/RicCreateGridCrossPlotFeature.cpp +++ b/ApplicationLibCode/Commands/GridCrossPlotCommands/RicCreateGridCrossPlotFeature.cpp @@ -82,8 +82,8 @@ void RicCreateGridCrossPlotFeature::onActionTriggered( bool isChecked ) collection->updateAllRequiredEditors(); RiaGuiApplication::instance()->getOrCreateAndShowMainPlotWindow(); - RiuPlotMainWindowTools::selectAsCurrentItem( dataSet ); - RiuPlotMainWindowTools::refreshToolbars(); + + RiuPlotMainWindowTools::onObjectAppended( dataSet ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/GridCrossPlotCommands/RicCreateSaturationPressurePlotsFeature.cpp b/ApplicationLibCode/Commands/GridCrossPlotCommands/RicCreateSaturationPressurePlotsFeature.cpp index 78d835de4f..a325fab989 100644 --- a/ApplicationLibCode/Commands/GridCrossPlotCommands/RicCreateSaturationPressurePlotsFeature.cpp +++ b/ApplicationLibCode/Commands/GridCrossPlotCommands/RicCreateSaturationPressurePlotsFeature.cpp @@ -199,8 +199,7 @@ void RicCreateSaturationPressurePlotsFeature::onActionTriggered( bool isChecked if ( objectToSelect ) { - RiuPlotMainWindowTools::selectAsCurrentItem( objectToSelect ); - RiuPlotMainWindowTools::refreshToolbars(); + RiuPlotMainWindowTools::onObjectAppended( objectToSelect ); } } diff --git a/ApplicationLibCode/Commands/PlotBuilderCommands/RicSummaryPlotBuilder.cpp b/ApplicationLibCode/Commands/PlotBuilderCommands/RicSummaryPlotBuilder.cpp index 9e3dfcd53d..0cec5d2ae8 100644 --- a/ApplicationLibCode/Commands/PlotBuilderCommands/RicSummaryPlotBuilder.cpp +++ b/ApplicationLibCode/Commands/PlotBuilderCommands/RicSummaryPlotBuilder.cpp @@ -342,11 +342,11 @@ RimMultiPlot* RicSummaryPlotBuilder::createAndAppendMultiPlot( const std::vector if ( !plots.empty() ) { - RiuPlotMainWindowTools::selectAsCurrentItem( plots[0], true ); + RiuPlotMainWindowTools::selectAsCurrentItem( plots[0] ); } else { - RiuPlotMainWindowTools::selectAsCurrentItem( plotWindow, true ); + RiuPlotMainWindowTools::selectAsCurrentItem( plotWindow ); } return plotWindow; @@ -374,12 +374,12 @@ RimSummaryMultiPlot* if ( plotWindow->summaryPlots().size() == 1 ) { RiuPlotMainWindowTools::selectAsCurrentItem( plotWindow->summaryPlots()[0] ); - RiuPlotMainWindowTools::setExpanded( plotWindow->summaryPlots()[0], true ); + RiuPlotMainWindowTools::setExpanded( plotWindow->summaryPlots()[0] ); } else { RiuPlotMainWindowTools::selectAsCurrentItem( plotWindow ); - RiuPlotMainWindowTools::setExpanded( plotWindow, true ); + RiuPlotMainWindowTools::setExpanded( plotWindow ); } return plotWindow; diff --git a/ApplicationLibCode/Commands/RicCreateEnsembleFractureStatisticsPlotFeature.cpp b/ApplicationLibCode/Commands/RicCreateEnsembleFractureStatisticsPlotFeature.cpp index 474d33a559..165edf718c 100644 --- a/ApplicationLibCode/Commands/RicCreateEnsembleFractureStatisticsPlotFeature.cpp +++ b/ApplicationLibCode/Commands/RicCreateEnsembleFractureStatisticsPlotFeature.cpp @@ -59,8 +59,7 @@ void RicCreateEnsembleFractureStatisticsPlotFeature::onActionTriggered( bool isC collection->addEnsembleFractureStatisticsPlot( plot ); collection->updateAllRequiredEditors(); RiaGuiApplication::instance()->getOrCreateAndShowMainPlotWindow(); - RiuPlotMainWindowTools::selectAsCurrentItem( plot ); - RiuPlotMainWindowTools::refreshToolbars(); + RiuPlotMainWindowTools::onObjectAppended( plot ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/RicCreateEnsembleWellLogFeature.cpp b/ApplicationLibCode/Commands/RicCreateEnsembleWellLogFeature.cpp index 2485e1fa45..0b7cf3cd02 100644 --- a/ApplicationLibCode/Commands/RicCreateEnsembleWellLogFeature.cpp +++ b/ApplicationLibCode/Commands/RicCreateEnsembleWellLogFeature.cpp @@ -272,8 +272,7 @@ void RicCreateEnsembleWellLogFeature::executeCommand( const RicCreateEnsembleWel wellLogPlot->updateConnectedEditors(); RiuPlotMainWindowTools::showPlotMainWindow(); - RiuPlotMainWindowTools::selectAsCurrentItem( wellLogPlot ); - RiuPlotMainWindowTools::refreshToolbars(); + RiuPlotMainWindowTools::onObjectAppended( wellLogPlot ); } } } diff --git a/ApplicationLibCode/Commands/RicCreateGridStatisticsPlotFeature.cpp b/ApplicationLibCode/Commands/RicCreateGridStatisticsPlotFeature.cpp index 3c81d2b015..63bc5c7192 100644 --- a/ApplicationLibCode/Commands/RicCreateGridStatisticsPlotFeature.cpp +++ b/ApplicationLibCode/Commands/RicCreateGridStatisticsPlotFeature.cpp @@ -64,8 +64,7 @@ void RicCreateGridStatisticsPlotFeature::onActionTriggered( bool isChecked ) collection->addGridStatisticsPlot( plot ); collection->updateAllRequiredEditors(); RiaGuiApplication::instance()->getOrCreateAndShowMainPlotWindow(); - RiuPlotMainWindowTools::selectAsCurrentItem( plot ); - RiuPlotMainWindowTools::refreshToolbars(); + RiuPlotMainWindowTools::onObjectAppended( plot ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/RicImportSummaryCasesFeature.cpp b/ApplicationLibCode/Commands/RicImportSummaryCasesFeature.cpp index 55f5e34b9d..0ecdb8968d 100644 --- a/ApplicationLibCode/Commands/RicImportSummaryCasesFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportSummaryCasesFeature.cpp @@ -143,9 +143,7 @@ bool RicImportSummaryCasesFeature::createAndAddSummaryCasesFromFiles( const QStr if ( plotToSelect ) { - RiuPlotMainWindowTools::setExpanded( plotToSelect ); - RiuPlotMainWindowTools::selectAsCurrentItem( plotToSelect ); - RiuPlotMainWindowTools::refreshToolbars(); + RiuPlotMainWindowTools::onObjectAppended( plotToSelect ); } } diff --git a/ApplicationLibCode/Commands/RicNewCustomObjectiveFunctionWeightFeature.cpp b/ApplicationLibCode/Commands/RicNewCustomObjectiveFunctionWeightFeature.cpp index d50a37dfb4..142ba1c469 100644 --- a/ApplicationLibCode/Commands/RicNewCustomObjectiveFunctionWeightFeature.cpp +++ b/ApplicationLibCode/Commands/RicNewCustomObjectiveFunctionWeightFeature.cpp @@ -56,8 +56,7 @@ void RicNewCustomObjectiveFunctionWeightFeature::onActionTriggered( bool isCheck auto newWeight = RimObjectiveFunctionTools::addWeight( firstObjectiveFunction ); firstObjectiveFunction->updateConnectedEditors(); - RiuPlotMainWindowTools::selectAsCurrentItem( newWeight ); - RiuPlotMainWindowTools::setExpanded( func.front() ); + RiuPlotMainWindowTools::onObjectAppended( newWeight, func.front() ); } selObj->updateConnectedEditors(); diff --git a/ApplicationLibCode/Commands/RicNewVfpPlotFeature.cpp b/ApplicationLibCode/Commands/RicNewVfpPlotFeature.cpp index ddbdeed945..b7ec8f0e1a 100644 --- a/ApplicationLibCode/Commands/RicNewVfpPlotFeature.cpp +++ b/ApplicationLibCode/Commands/RicNewVfpPlotFeature.cpp @@ -97,8 +97,7 @@ void RicNewVfpPlotFeature::onActionTriggered( bool isChecked ) if ( !vfpPlots.empty() ) { - RiuPlotMainWindowTools::selectAsCurrentItem( vfpPlots.front() ); - RiuPlotMainWindowTools::refreshToolbars(); + RiuPlotMainWindowTools::onObjectAppended( vfpPlots.front() ); } } } diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotCurveFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotCurveFeature.cpp index 0d25918a57..2b014adcb1 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotCurveFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotCurveFeature.cpp @@ -75,9 +75,7 @@ void RicNewSummaryCrossPlotCurveFeature::onActionTriggered( bool isChecked ) plot->updateConnectedEditors(); - RiaGuiApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem( newCurve ); - - RiuPlotMainWindowTools::refreshToolbars(); + RiuPlotMainWindowTools::onObjectAppended( newCurve ); } } diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.cpp index a0fd75ff6f..5304487c80 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.cpp @@ -88,9 +88,7 @@ void RicNewSummaryCrossPlotFeature::onActionTriggered( bool isChecked ) summaryPlot->loadDataAndUpdate(); RiuPlotMainWindowTools::showPlotMainWindow(); - RiuPlotMainWindowTools::selectAsCurrentItem( summaryPlot ); - RiuPlotMainWindowTools::setExpanded( summaryPlot ); - RiuPlotMainWindowTools::refreshToolbars(); + RiuPlotMainWindowTools::onObjectAppended( summaryPlot ); } } diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp index 981dd0d565..cb96a51497 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp @@ -105,9 +105,7 @@ void RicAddWellLogToPlotFeature::onActionTriggered( bool isChecked ) plot->updateLayout(); RiuPlotMainWindowTools::showPlotMainWindow(); - RiuPlotMainWindowTools::selectAsCurrentItem( plot ); - RiuPlotMainWindowTools::setExpanded( plotTrack ); - RiuPlotMainWindowTools::refreshToolbars(); + RiuPlotMainWindowTools::onObjectAppended( plot, plotTrack ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewEnsembleWellLogCurveSetFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicNewEnsembleWellLogCurveSetFeature.cpp index ac990ccdcf..3368af313b 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewEnsembleWellLogCurveSetFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewEnsembleWellLogCurveSetFeature.cpp @@ -52,9 +52,9 @@ void RicNewEnsembleWellLogCurveSetFeature::onActionTriggered( bool isChecked ) RimEnsembleWellLogCurveSet* curveSet = new RimEnsembleWellLogCurveSet(); wellLogPlotTrack->setEnsembleWellLogCurveSet( curveSet ); wellLogPlotTrack->updateEditors(); - RiuPlotMainWindowTools::selectAsCurrentItem( curveSet ); + + RiuPlotMainWindowTools::onObjectAppended( curveSet ); } - RiuPlotMainWindowTools::refreshToolbars(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewPltPlotFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicNewPltPlotFeature.cpp index a83dce0b56..f073a79496 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewPltPlotFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewPltPlotFeature.cpp @@ -121,9 +121,7 @@ void RicNewPltPlotFeature::onActionTriggered( bool isChecked ) pltPlotColl->updateConnectedEditors(); RiuPlotMainWindowTools::showPlotMainWindow(); - RiuPlotMainWindowTools::setExpanded( plotTrack ); - RiuPlotMainWindowTools::selectAsCurrentItem( pltPlot ); - RiuPlotMainWindowTools::refreshToolbars(); + RiuPlotMainWindowTools::onObjectAppended( pltPlot, plotTrack ); } } diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewRftPlotFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicNewRftPlotFeature.cpp index 82fe37f957..79013707a1 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewRftPlotFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewRftPlotFeature.cpp @@ -85,9 +85,7 @@ void RicNewRftPlotFeature::onActionTriggered( bool isChecked ) rftPlotColl->updateConnectedEditors(); RiuPlotMainWindowTools::showPlotMainWindow(); - RiuPlotMainWindowTools::setExpanded( plotTrack ); - RiuPlotMainWindowTools::selectAsCurrentItem( rftPlot ); - RiuPlotMainWindowTools::refreshToolbars(); + RiuPlotMainWindowTools::onObjectAppended( rftPlot, plotTrack ); } } diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewRftSegmentWellLogPlotFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicNewRftSegmentWellLogPlotFeature.cpp index 3ded3d50ee..92a585ff1c 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewRftSegmentWellLogPlotFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewRftSegmentWellLogPlotFeature.cpp @@ -84,8 +84,7 @@ void RicNewRftSegmentWellLogPlotFeature::onActionTriggered( bool isChecked ) appendTrackAndCurveForBranchType( plot, resultName, branchType, summaryCase ); } - RiuPlotMainWindowTools::selectAsCurrentItem( plot ); - RiuPlotMainWindowTools::refreshToolbars(); + RiuPlotMainWindowTools::onObjectAppended( plot ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewRftWellLogPlotFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicNewRftWellLogPlotFeature.cpp index 958e6a09fc..ca3d56bbd6 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewRftWellLogPlotFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewRftWellLogPlotFeature.cpp @@ -76,10 +76,7 @@ void RicNewRftWellLogPlotFeature::onActionTriggered( bool isChecked ) curve->updateAllRequiredEditors(); - RiuPlotMainWindowTools::setExpanded( curve ); - RiuPlotMainWindowTools::selectAsCurrentItem( curve ); - - RiuPlotMainWindowTools::refreshToolbars(); + RiuPlotMainWindowTools::onObjectAppended( curve ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp index 4cce4a286d..b15dbaf862 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp @@ -120,11 +120,8 @@ RimWellBoreStabilityPlot* RicNewWellLogPlotFeatureImpl::updateAfterCreation( plot ); } - RiuPlotMainWindowTools::selectAsCurrentItem( plot ); - - // Make sure the summary plot window is visible RiuPlotMainWindowTools::showPlotMainWindow(); - RiuPlotMainWindowTools::refreshToolbars(); + RiuPlotMainWindowTools::onObjectAppended( plot ); return plot; } diff --git a/ApplicationLibCode/ProjectDataModel/RimObservedDataCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimObservedDataCollection.cpp index 7b7bc9d88d..837e4d916a 100644 --- a/ApplicationLibCode/ProjectDataModel/RimObservedDataCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimObservedDataCollection.cpp @@ -122,8 +122,7 @@ bool RimObservedDataCollection::fileExists( const QString& fileName, QString* er void updateNewObservedDataCreated( caf::PdmObject* object ) { RiuPlotMainWindowTools::showPlotMainWindow(); - RiuPlotMainWindowTools::selectAsCurrentItem( object ); - RiuPlotMainWindowTools::setExpanded( object ); + RiuPlotMainWindowTools::onObjectAppended( object ); caf::PdmUiObjectEditorHandle::updateUiAllObjectEditors(); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp index 609c967c98..8c33351516 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlot.cpp @@ -1397,7 +1397,7 @@ void RimSummaryMultiPlot::appendSubPlotByStepping( int direction ) loadDataAndUpdate(); updateConnectedEditors(); - RiuPlotMainWindowTools::selectAsCurrentItem( newPlots.back(), true ); + RiuPlotMainWindowTools::selectAsCurrentItem( newPlots.back() ); updateSourceStepper(); RiuPlotMainWindowTools::refreshToolbars(); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlotCollection.cpp index 018e4fe6d4..5f5eed054f 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryMultiPlotCollection.cpp @@ -174,7 +174,7 @@ void RimSummaryMultiPlotCollection::duplicatePlot( RimSummaryMultiPlot* plotToDu updateConnectedEditors(); - RiuPlotMainWindowTools::selectAsCurrentItem( plotCopy, true ); + RiuPlotMainWindowTools::selectAsCurrentItem( plotCopy ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.cpp b/ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.cpp index 262ed61c9d..d81d95ab43 100644 --- a/ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.cpp +++ b/ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.cpp @@ -47,25 +47,27 @@ void RiuPlotMainWindowTools::setActiveViewer( QWidget* subWindow ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuPlotMainWindowTools::setExpanded( const caf::PdmUiItem* uiItem, bool expanded /*= true*/ ) +void RiuPlotMainWindowTools::setExpanded( const caf::PdmUiItem* uiItem ) { if ( RiaGuiApplication::isRunning() ) { RiuPlotMainWindow* mpw = RiaGuiApplication::instance()->mainPlotWindow(); - if ( mpw ) mpw->setExpanded( uiItem, expanded ); + bool expand = true; + if ( mpw ) mpw->setExpanded( uiItem, expand ); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuPlotMainWindowTools::selectAsCurrentItem( const caf::PdmObject* object, bool allowActiveViewChange /*= true*/ ) +void RiuPlotMainWindowTools::selectAsCurrentItem( const caf::PdmObject* object ) { if ( RiaGuiApplication::isRunning() ) { RiuPlotMainWindow* mpw = RiaGuiApplication::instance()->mainPlotWindow(); + bool allowActiveViewChange = true; if ( mpw ) mpw->selectAsCurrentItem( object, allowActiveViewChange ); } } @@ -73,12 +75,13 @@ void RiuPlotMainWindowTools::selectAsCurrentItem( const caf::PdmObject* object, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuPlotMainWindowTools::toggleItemInSelection( const caf::PdmObject* object, bool allowActiveViewChange /*= true*/ ) +void RiuPlotMainWindowTools::toggleItemInSelection( const caf::PdmObject* object ) { if ( RiaGuiApplication::isRunning() ) { RiuPlotMainWindow* mpw = RiaGuiApplication::instance()->mainPlotWindow(); + bool allowActiveViewChange = true; if ( mpw ) mpw->toggleItemInSelection( object, allowActiveViewChange ); } } @@ -114,3 +117,16 @@ void RiuPlotMainWindowTools::refreshToolbars() } } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotMainWindowTools::onObjectAppended( const caf::PdmObject* objectToSelect, const caf::PdmObject* objectToExpand ) +{ + if ( objectToExpand == nullptr ) objectToExpand = objectToSelect; + + if ( objectToExpand ) RiuPlotMainWindowTools::setExpanded( objectToExpand ); + if ( objectToSelect ) RiuPlotMainWindowTools::selectAsCurrentItem( objectToSelect ); + + RiuPlotMainWindowTools::refreshToolbars(); +} diff --git a/ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.h b/ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.h index 38da6f5cb6..96c6a1218b 100644 --- a/ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.h +++ b/ApplicationLibCode/UserInterface/RiuPlotMainWindowTools.h @@ -31,9 +31,15 @@ class RiuPlotMainWindowTools public: static void showPlotMainWindow(); static void setActiveViewer( QWidget* subWindow ); - static void setExpanded( const caf::PdmUiItem* uiItem, bool expanded = true ); - static void selectAsCurrentItem( const caf::PdmObject* object, bool allowActiveViewChange = true ); - static void toggleItemInSelection( const caf::PdmObject* object, bool allowActiveViewChange = true ); + static void setExpanded( const caf::PdmUiItem* uiItem ); + static void selectAsCurrentItem( const caf::PdmObject* object ); static void selectOrToggleObject( const caf::PdmObject* object, bool toggle ); static void refreshToolbars(); + + // Use this function to select (and expand) an object in the project tree and update tool bars. Use the second + // parameter to expand a different object than the object to be selected. + static void onObjectAppended( const caf::PdmObject* objectToSelect, const caf::PdmObject* objectToExpand = nullptr ); + +private: + static void toggleItemInSelection( const caf::PdmObject* object ); };