From 63eac19c070501850092551fb17f7e8fac1a11b0 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Tue, 17 Sep 2019 19:07:55 +0200 Subject: [PATCH] #4727 Apply initial default well path for new RFT Plots --- .../WellLogCommands/RicNewRftPlotFeature.cpp | 8 ++-- .../ProjectDataModel/Flow/RimWellRftPlot.cpp | 45 +++++++++++-------- .../ProjectDataModel/Flow/RimWellRftPlot.h | 8 ++-- 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewRftPlotFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewRftPlotFeature.cpp index b2692b51d3..dfd095cb15 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewRftPlotFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewRftPlotFeature.cpp @@ -67,8 +67,6 @@ void RicNewRftPlotFeature::onActionTriggered( bool isChecked ) { QString wellName = selectedWellName(); - QString plotName = QString( RimWellRftPlot::plotNameFormatString() ).arg( wellName ); - RimWellRftPlot* rftPlot = new RimWellRftPlot(); rftPlot->setSimWellOrWellPathName( wellName ); @@ -77,9 +75,13 @@ void RicNewRftPlotFeature::onActionTriggered( bool isChecked ) plotTrack->setDescription( QString( "Track %1" ).arg( rftPlot->trackCount() ) ); rftPlotColl->addPlot( rftPlot ); + rftPlot->applyInitialSelections(); + + wellName = rftPlot->simWellOrWellPathName(); // We may have been given a default well name + QString plotName = QString( RimWellRftPlot::plotNameFormatString() ).arg( wellName ); + rftPlot->setDescription( plotName ); - rftPlot->applyInitialSelections(); rftPlot->loadDataAndUpdate(); rftPlotColl->updateConnectedEditors(); diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp index 951a2af4c9..d5c692765f 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp @@ -221,6 +221,12 @@ QString RimWellRftPlot::associatedSimWellName() const //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::applyInitialSelections() { + std::map wellSources = findWellSources(); + if ( m_wellPathNameOrSimWellName == "None" && !wellSources.empty() ) + { + m_wellPathNameOrSimWellName = wellSources.begin()->first; + } + std::vector sourcesToSelect; const QString simWellName = associatedSimWellName(); @@ -637,7 +643,20 @@ QList RimWellRftPlot::calculateValueOptions( const caf:: if ( fieldNeedingOptions == &m_wellPathNameOrSimWellName ) { - calculateValueOptionsForWells( options ); + options.push_back( caf::PdmOptionItemInfo( "None", "None" ) ); + + std::map wellSources = findWellSources(); + for ( const auto& wellName : wellSources ) + { + const QStringList& tags = wellName.second; + QString uiText = wellName.first; + if ( !tags.empty() ) + { + uiText += QString( " (%1)" ).arg( wellName.second.join( ", " ) ); + } + + options.push_back( caf::PdmOptionItemInfo( uiText, wellName.first ) ); + } } else if ( fieldNeedingOptions == &m_selectedSources ) { @@ -847,17 +866,16 @@ void RimWellRftPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellRftPlot::calculateValueOptionsForWells( QList& options ) +std::map RimWellRftPlot::findWellSources() { - RimProject* proj = RiaApplication::instance()->project(); + std::map wellNames; - options.push_back( caf::PdmOptionItemInfo( "None", "None" ) ); + RimProject* proj = RiaApplication::instance()->project(); if ( proj != nullptr ) { - const std::vector simWellNames = proj->simulationWellNames(); - std::set simWellsAssociatedWithWellPath; - std::map wellNames; + const std::vector simWellNames = proj->simulationWellNames(); + std::set simWellsAssociatedWithWellPath; // Observed wells for ( RimWellPath* const wellPath : proj->allWellPaths() ) @@ -903,19 +921,8 @@ void RimWellRftPlot::calculateValueOptionsForWells( QList& options ); - void updateEditorsFromCurves(); - void syncCurvesFromUiSelection(); - void assignWellPathToExtractionCurves(); + std::map findWellSources(); + void updateEditorsFromCurves(); + void syncCurvesFromUiSelection(); + void assignWellPathToExtractionCurves(); RimObservedFmuRftData* findObservedFmuData( const QString& wellPathName, const QDateTime& timeStep ) const;