From 10a01972f3ddb95830cc9715097bbc81757ff203 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 24 Feb 2022 10:03:30 +0100 Subject: [PATCH] #8583 RFT Plots : Add support for data source management to well log plots --- .../Commands/RicWellLogTools.cpp | 11 ++ .../RicChangeDataSourceFeature.cpp | 4 +- .../ProjectDataModel/RimDepthTrackPlot.cpp | 2 +- .../WellLog/CMakeLists_files.cmake | 2 + .../WellLog/Rim3dWellLogRftCurve.cpp | 30 +--- .../ProjectDataModel/WellLog/RimRftTools.cpp | 168 ++++++++++++++++++ .../ProjectDataModel/WellLog/RimRftTools.h | 46 +++++ .../RimWellLogCurveCommonDataSource.cpp | 123 ++++++++++--- .../WellLog/RimWellLogCurveCommonDataSource.h | 18 +- .../WellLog/RimWellLogRftCurve.cpp | 124 +++++-------- .../WellLog/RimWellLogRftCurve.h | 7 + 11 files changed, 396 insertions(+), 139 deletions(-) create mode 100644 ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.h diff --git a/ApplicationLibCode/Commands/RicWellLogTools.cpp b/ApplicationLibCode/Commands/RicWellLogTools.cpp index 91464ac211..997f6dece3 100644 --- a/ApplicationLibCode/Commands/RicWellLogTools.cpp +++ b/ApplicationLibCode/Commands/RicWellLogTools.cpp @@ -368,6 +368,17 @@ RimWellLogRftCurve* plotTrack->setFormationCase( resultCase ); plotTrack->setFormationSimWellName( simWell->name() ); } + else if ( resultCase ) + { + curve->setEclipseResultCase( resultCase ); + + auto wellNames = resultCase->rftReader()->wellNames(); + if ( !wellNames.empty() ) + { + auto wellName = *( wellNames.begin() ); + curve->setDefaultAddress( wellName ); + } + } cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable( plotTrack->curveCount() ); curve->setColor( curveColor ); diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicChangeDataSourceFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicChangeDataSourceFeature.cpp index 789a246023..439c57409d 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicChangeDataSourceFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicChangeDataSourceFeature.cpp @@ -66,14 +66,14 @@ void RicChangeDataSourceFeature::onActionTriggered( bool isChecked ) if ( selectedTracksAndCurves( &curves, &tracks ) ) { RimWellLogCurveCommonDataSource featureUi; - featureUi.updateDefaultOptions( curves, tracks ); + featureUi.analyseCurvesAndTracks( curves, tracks ); caf::PdmUiPropertyViewDialog propertyDialog( nullptr, &featureUi, "Change Data Source for Multiple Curves", "" ); propertyDialog.resize( QSize( 500, 200 ) ); if ( propertyDialog.exec() == QDialog::Accepted ) { - featureUi.updateCurvesAndTracks( curves, tracks ); + featureUi.applyDataSourceChanges( curves, tracks ); } } } diff --git a/ApplicationLibCode/ProjectDataModel/RimDepthTrackPlot.cpp b/ApplicationLibCode/ProjectDataModel/RimDepthTrackPlot.cpp index 2aa90e6691..309c682fc2 100644 --- a/ApplicationLibCode/ProjectDataModel/RimDepthTrackPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimDepthTrackPlot.cpp @@ -670,7 +670,7 @@ RimWellLogCurveCommonDataSource* RimDepthTrackPlot::commonDataSource() const //-------------------------------------------------------------------------------------------------- void RimDepthTrackPlot::updateCommonDataSource() { - m_commonDataSource->updateDefaultOptions(); + m_commonDataSource->analyseCurvesAndTracks(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake index 861abfda47..334773ffc9 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/WellLog/CMakeLists_files.cmake @@ -23,6 +23,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileCurve.h ${CMAKE_CURRENT_LIST_DIR}/RimWellLogRftCurve.h ${CMAKE_CURRENT_LIST_DIR}/RimWellLogWbsCurve.h + ${CMAKE_CURRENT_LIST_DIR}/RimRftTools.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -50,6 +51,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimEnsembleWellLogCurveSet.cpp ${CMAKE_CURRENT_LIST_DIR}/RimEnsembleWellLogStatistics.cpp ${CMAKE_CURRENT_LIST_DIR}/RimEnsembleWellLogStatisticsCurve.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimRftTools.cpp ) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogRftCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogRftCurve.cpp index d01839d60b..9fa5771eaf 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogRftCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogRftCurve.cpp @@ -25,6 +25,7 @@ #include "RigWellLogCurveData.h" #include "RimEclipseResultCase.h" +#include "RimRftTools.h" #include "RimTools.h" #include "RimWellLogCurve.h" #include "RimWellLogRftCurve.h" @@ -174,23 +175,7 @@ QList if ( m_eclipseResultCase ) { RifReaderRftInterface* reader = m_eclipseResultCase()->rftReader(); - if ( reader ) - { - for ( const RifEclipseRftAddress::RftWellLogChannelType& channelName : - reader->availableWellLogChannels( wellName() ) ) - { - options.push_back( - caf::PdmOptionItemInfo( caf::AppEnum::uiText( - channelName ), - channelName ) ); - } - } - if ( options.empty() ) - { - options.push_back( caf::PdmOptionItemInfo( caf::AppEnum::uiText( - RifEclipseRftAddress::RftWellLogChannelType::NONE ), - RifEclipseRftAddress::RftWellLogChannelType::NONE ) ); - } + options = RimRftTools::wellLogChannelsOptions( reader, wellName() ); } } else if ( fieldNeedingOptions == &m_timeStep ) @@ -200,17 +185,8 @@ QList RifReaderRftInterface* reader = m_eclipseResultCase()->rftReader(); if ( reader ) { - QString dateFormat = "dd MMM yyyy"; - std::set timeStamps = reader->availableTimeSteps( wellName(), m_wellLogChannelName() ); - for ( const QDateTime& dt : timeStamps ) - { - QString dateString = RiaQDateTimeTools::toStringUsingApplicationLocale( dt, dateFormat ); - - options.push_back( caf::PdmOptionItemInfo( dateString, dt ) ); - } + options = RimRftTools::timeStepOptions( reader, wellName(), m_wellLogChannelName() ); } - - options.push_back( caf::PdmOptionItemInfo( "None", QDateTime() ) ); } } return options; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.cpp new file mode 100644 index 0000000000..a2da5205fb --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.cpp @@ -0,0 +1,168 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimRftTools.h" + +#include "RiaQDateTimeTools.h" +#include "RiaResultNames.h" +#include "RiaRftDefines.h" + +#include "RifReaderRftInterface.h" + +#include "cafPdmUiItem.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimRftTools::wellLogChannelsOptions( RifReaderRftInterface* readerRft, const QString& wellName ) +{ + QList options; + + if ( readerRft ) + { + for ( const RifEclipseRftAddress::RftWellLogChannelType& channelName : + readerRft->availableWellLogChannels( wellName ) ) + { + options.push_back( + caf::PdmOptionItemInfo( caf::AppEnum::uiText( channelName ), + channelName ) ); + } + } + + if ( options.empty() ) + { + options.push_back( caf::PdmOptionItemInfo( caf::AppEnum::uiText( + RifEclipseRftAddress::RftWellLogChannelType::NONE ), + RifEclipseRftAddress::RftWellLogChannelType::NONE ) ); + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimRftTools::wellNameOptions( RifReaderRftInterface* readerRft ) +{ + QList options; + + options.push_back( caf::PdmOptionItemInfo( "None", "" ) ); + if ( readerRft ) + { + std::set wellNames = readerRft->wellNames(); + for ( const QString& name : wellNames ) + { + options.push_back( caf::PdmOptionItemInfo( name, name, false, caf::IconProvider( ":/Well.svg" ) ) ); + } + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimRftTools::timeStepOptions( RifReaderRftInterface* readerRft, + const QString& wellName, + RifEclipseRftAddress::RftWellLogChannelType channelType ) +{ + QList options; + + if ( readerRft ) + { + QString dateFormat = "dd MMM yyyy"; + std::set timeStamps = readerRft->availableTimeSteps( wellName, channelType ); + for ( const QDateTime& dt : timeStamps ) + { + QString dateString = RiaQDateTimeTools::toStringUsingApplicationLocale( dt, dateFormat ); + + options.push_back( caf::PdmOptionItemInfo( dateString, dt ) ); + } + } + + options.push_back( caf::PdmOptionItemInfo( "None", QDateTime() ) ); + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimRftTools::segmentTimeStepOptions( RifReaderRftInterface* readerRft, const QString& wellName ) +{ + return timeStepOptions( readerRft, wellName, RifEclipseRftAddress::RftWellLogChannelType::SEGMENT_VALUES ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimRftTools::segmentResultNameOptions( RifReaderRftInterface* readerRft, + const QString& wellName, + const QDateTime& timeStep ) +{ + QList options; + + options.push_front( + caf::PdmOptionItemInfo( RiaResultNames::undefinedResultName(), RiaResultNames::undefinedResultName() ) ); + + if ( readerRft ) + { + options.push_back( + caf::PdmOptionItemInfo( RiaDefines::segmentNumberResultName(), RiaDefines::segmentNumberResultName() ) ); + + for ( const auto& resultAdr : readerRft->eclipseRftAddresses( wellName, timeStep ) ) + { + if ( resultAdr.wellLogChannel() == RifEclipseRftAddress::RftWellLogChannelType::SEGMENT_VALUES ) + { + options.push_back( caf::PdmOptionItemInfo( resultAdr.segmentResultName(), resultAdr.segmentResultName() ) ); + } + } + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimRftTools::segmentBranchIdOptions( RifReaderRftInterface* readerRft, + const QString& wellName, + const QDateTime& timeStep ) +{ + QList options; + + options.push_front( caf::PdmOptionItemInfo( RiaDefines::allBranches(), RiaDefines::allBranches() ) ); + + if ( readerRft ) + { + std::vector values; + + auto adr = + RifEclipseRftAddress::createSegmentResult( wellName, timeStep, RiaDefines::segmentBranchNumberResultName() ); + + readerRft->values( adr, &values ); + for ( const auto& v : values ) + { + int intValue = v; + auto txt = QString::number( intValue ); + options.push_back( caf::PdmOptionItemInfo( txt, txt ) ); + } + } + + return options; +} diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.h new file mode 100644 index 0000000000..fdc1e48f08 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.h @@ -0,0 +1,46 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2022- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RifEclipseRftAddress.h" + +#include + +namespace caf +{ +class PdmOptionItemInfo; +} +class RifReaderRftInterface; + +class RimRftTools +{ +public: + static QList wellLogChannelsOptions( RifReaderRftInterface* readerRft, const QString& wellName ); + static QList wellNameOptions( RifReaderRftInterface* readerRft ); + static QList timeStepOptions( RifReaderRftInterface* readerRft, + const QString& wellName, + RifEclipseRftAddress::RftWellLogChannelType channelType ); + + static QList segmentTimeStepOptions( RifReaderRftInterface* readerRft, const QString& wellName ); + + static QList + segmentResultNameOptions( RifReaderRftInterface* readerRft, const QString& wellName, const QDateTime& timeStep ); + static QList + segmentBranchIdOptions( RifReaderRftInterface* readerRft, const QString& wellName, const QDateTime& timeStep ); +}; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp index 710bb28041..2510035299 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp @@ -25,12 +25,14 @@ #include "RimGeoMechCase.h" #include "RimOilField.h" #include "RimProject.h" +#include "RimRftTools.h" #include "RimTools.h" #include "RimWellFlowRateCurve.h" #include "RimWellLogExtractionCurve.h" #include "RimWellLogFileCurve.h" #include "RimWellLogPlot.h" #include "RimWellLogPlotCollection.h" +#include "RimWellLogRftCurve.h" #include "RimWellLogTrack.h" #include "RimWellLogWbsCurve.h" #include "RimWellMeasurementCurve.h" @@ -96,6 +98,10 @@ RimWellLogCurveCommonDataSource::RimWellLogCurveCommonDataSource() CAF_PDM_InitField( &m_wbsSmoothingThreshold, "WBSSmoothingThreshold", -1.0, "Smoothing Threshold" ); + CAF_PDM_InitFieldNoDefault( &m_rftTimeStep, "RftTimeStep", "RFT Time Step" ); + CAF_PDM_InitFieldNoDefault( &m_rftWellName, "RftWellName", "RFT Well Name" ); + CAF_PDM_InitFieldNoDefault( &m_rftSegmentBranchId, "SegmentBranchId", "RFT Segment Branch" ); + m_case = nullptr; m_wellPath = nullptr; } @@ -276,13 +282,17 @@ void RimWellLogCurveCommonDataSource::resetDefaultOptions() m_uniqueBranchDetection.clear(); m_uniqueWbsSmoothing.clear(); m_uniqueWbsSmoothingThreshold.clear(); + + m_uniqueRftTimeSteps.clear(); + m_uniqueRftWellNames.clear(); + m_uniqueRftBranchIds.clear(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogCurveCommonDataSource::updateDefaultOptions( const std::vector& curves, - const std::vector& tracks ) +void RimWellLogCurveCommonDataSource::analyseCurvesAndTracks( const std::vector& curves, + const std::vector& tracks ) { // Reset all options in the UI resetDefaultOptions(); @@ -294,12 +304,14 @@ void RimWellLogCurveCommonDataSource::updateDefaultOptions( const std::vector( curve ); - RimWellLogFileCurve* fileCurve = dynamic_cast( curve ); - RimWellFlowRateCurve* flowRateCurve = dynamic_cast( curve ); + auto* extractionCurve = dynamic_cast( curve ); + auto* fileCurve = dynamic_cast( curve ); + auto* flowRateCurve = dynamic_cast( curve ); + auto* rftCurve = dynamic_cast( curve ); + if ( extractionCurve ) { - RimWellLogWbsCurve* wbsCurve = dynamic_cast( extractionCurve ); + auto* wbsCurve = dynamic_cast( extractionCurve ); if ( wbsCurve ) { m_uniqueWbsSmoothing.insert( wbsCurve->smoothCurve() ); @@ -341,6 +353,16 @@ void RimWellLogCurveCommonDataSource::updateDefaultOptions( const std::vectorrimCase() ); m_uniqueTimeSteps.insert( flowRateCurve->timeStep() ); } + else if ( rftCurve ) + { + m_uniqueWellNames.insert( rftCurve->wellName() ); + m_uniqueCases.insert( rftCurve->eclipseResultCase() ); + + auto adr = rftCurve->rftAddress(); + m_uniqueRftWellNames.insert( adr.wellName() ); + m_uniqueRftTimeSteps.insert( adr.timeStep() ); + m_uniqueRftBranchIds.insert( QString::number( adr.segmentBranchNumber() ) ); + } } for ( RimWellLogTrack* track : tracks ) { @@ -411,12 +433,22 @@ void RimWellLogCurveCommonDataSource::updateDefaultOptions( const std::vectorfirstAncestorOrThisOfType( parentPlot ); @@ -428,15 +460,15 @@ void RimWellLogCurveCommonDataSource::updateDefaultOptions() std::vector tracks; parentPlot->descendantsIncludingThisOfType( tracks ); - this->updateDefaultOptions( curves, tracks ); + this->analyseCurvesAndTracks( curves, tracks ); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogCurveCommonDataSource::updateCurvesAndTracks( const std::vector& curves, - const std::vector& tracks ) +void RimWellLogCurveCommonDataSource::applyDataSourceChanges( const std::vector& curves, + const std::vector& tracks ) { std::set plots; for ( RimWellLogCurve* curve : curves ) @@ -445,9 +477,10 @@ void RimWellLogCurveCommonDataSource::updateCurvesAndTracks( const std::vector( curve ); - RimWellLogExtractionCurve* extractionCurve = dynamic_cast( curve ); - RimWellMeasurementCurve* measurementCurve = dynamic_cast( curve ); + auto* fileCurve = dynamic_cast( curve ); + auto* extractionCurve = dynamic_cast( curve ); + auto* measurementCurve = dynamic_cast( curve ); + auto* rftCurve = dynamic_cast( curve ); if ( fileCurve ) { if ( wellPathToApply() != nullptr ) @@ -512,7 +545,7 @@ void RimWellLogCurveCommonDataSource::updateCurvesAndTracks( const std::vector( extractionCurve ); + auto* wbsCurve = dynamic_cast( extractionCurve ); if ( wbsCurve ) { if ( !wbsSmoothingToApply().isPartiallyTrue() ) @@ -542,6 +575,16 @@ void RimWellLogCurveCommonDataSource::updateCurvesAndTracks( const std::vectorsetWellPath( wellPathToApply() ); } } + else if ( rftCurve ) + { + rftCurve->setTimeStep( m_rftTimeStep() ); + rftCurve->setWellName( m_rftWellName() ); + rftCurve->setSegmentBranchId( m_rftSegmentBranchId() ); + + RimWellLogPlot* parentPlot = nullptr; + rftCurve->firstAncestorOrThisOfTypeAsserted( parentPlot ); + plots.insert( parentPlot ); + } } for ( RimWellLogTrack* track : tracks ) @@ -607,7 +650,7 @@ void RimWellLogCurveCommonDataSource::updateCurvesAndTracks( const std::vectorfirstAncestorOrThisOfType( parentPlot ); @@ -619,7 +662,7 @@ void RimWellLogCurveCommonDataSource::updateCurvesAndTracks() std::vector tracks; parentPlot->descendantsIncludingThisOfType( tracks ); - this->updateCurvesAndTracks( curves, tracks ); + this->applyDataSourceChanges( curves, tracks ); } } @@ -690,7 +733,7 @@ void RimWellLogCurveCommonDataSource::applyNextTimeStep() //-------------------------------------------------------------------------------------------------- std::vector RimWellLogCurveCommonDataSource::fieldsToShowInToolbar() { - updateDefaultOptions(); + analyseCurvesAndTracks(); std::vector fieldsToDisplay; fieldsToDisplay.push_back( &m_case ); @@ -741,7 +784,7 @@ void RimWellLogCurveCommonDataSource::fieldChangedByUi( const caf::PdmFieldHandl } } - this->updateCurvesAndTracks(); + this->applyDataSourceChanges(); } //-------------------------------------------------------------------------------------------------- @@ -753,7 +796,7 @@ QList { QList options; - this->updateDefaultOptions(); + this->analyseCurvesAndTracks(); if ( fieldNeedingOptions == &m_case ) { @@ -840,7 +883,7 @@ QList } else if ( fieldNeedingOptions == &m_simWellName ) { - RimEclipseCase* eclipseCase = dynamic_cast( m_case() ); + auto* eclipseCase = dynamic_cast( m_case() ); if ( eclipseCase ) { std::set sortedWellNames = eclipseCase->sortedSimWellNames(); @@ -887,6 +930,30 @@ QList } } } + else if ( fieldNeedingOptions == &m_rftTimeStep ) + { + auto eclipseCase = dynamic_cast( m_case() ); + if ( eclipseCase && eclipseCase->rftReader() ) + { + options = RimRftTools::segmentTimeStepOptions( eclipseCase->rftReader(), *( m_uniqueRftWellNames.begin() ) ); + } + } + else if ( fieldNeedingOptions == &m_rftWellName ) + { + auto eclipseCase = dynamic_cast( m_case() ); + if ( eclipseCase && eclipseCase->rftReader() ) + { + options = RimRftTools::wellNameOptions( eclipseCase->rftReader() ); + } + } + else if ( fieldNeedingOptions == &m_rftSegmentBranchId ) + { + auto eclipseCase = dynamic_cast( m_case() ); + if ( eclipseCase && eclipseCase->rftReader() ) + { + options = RimRftTools::segmentBranchIdOptions( eclipseCase->rftReader(), m_rftWellName(), m_rftTimeStep() ); + } + } return options; } @@ -896,12 +963,12 @@ QList //-------------------------------------------------------------------------------------------------- void RimWellLogCurveCommonDataSource::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { - updateDefaultOptions(); + analyseCurvesAndTracks(); caf::PdmUiGroup* group = uiOrdering.addNewGroup( "Data Source" ); group->add( &m_case ); - RimEclipseCase* eclipseCase = dynamic_cast( m_case() ); + auto* eclipseCase = dynamic_cast( m_case() ); if ( eclipseCase ) { group->add( &m_trajectoryType ); @@ -939,6 +1006,10 @@ void RimWellLogCurveCommonDataSource::defineUiOrdering( QString uiConfigName, ca group->add( &m_wbsSmoothingThreshold ); } + group->add( &m_rftWellName ); + group->add( &m_rftTimeStep ); + group->add( &m_rftSegmentBranchId ); + uiOrdering.skipRemainingFields( true ); } @@ -949,10 +1020,11 @@ void RimWellLogCurveCommonDataSource::defineEditorAttribute( const caf::PdmField QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) { - caf::PdmUiComboBoxEditorAttribute* myAttr = dynamic_cast( attribute ); + auto* myAttr = dynamic_cast( attribute ); if ( myAttr ) { - if ( field == &m_case || field == &m_simWellName || field == &m_wellPath || field == &m_timeStep ) + if ( field == &m_case || field == &m_simWellName || field == &m_wellPath || field == &m_timeStep || + field == &m_rftTimeStep || field == &m_rftSegmentBranchId ) { myAttr->showPreviousAndNextButtons = true; myAttr->nextIcon = QIcon( ":/ComboBoxDown.svg" ); @@ -982,8 +1054,7 @@ void RimWellLogCurveCommonDataSource::defineEditorAttribute( const caf::PdmField myAttr->prevButtonText = "Previous " + modifierText + "PgUp)"; } } - caf::PdmUiLineEditorAttributeUiDisplayString* uiDisplayStringAttr = - dynamic_cast( attribute ); + auto* uiDisplayStringAttr = dynamic_cast( attribute ); if ( uiDisplayStringAttr && wbsSmoothingThreshold() == -1.0 ) { QString displayString = "Mixed"; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.h index 5af6ba4f29..67d9b74ea5 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.h @@ -26,6 +26,8 @@ #include "cafPdmUiOrdering.h" #include "cafTristate.h" +#include + class RimCase; class RimWellLogCurve; class RimWellLogPlot; @@ -75,10 +77,10 @@ public: void setTimeStepToApply( int val ); void resetDefaultOptions(); - void updateDefaultOptions( const std::vector& curves, const std::vector& tracks ); - void updateDefaultOptions(); - void updateCurvesAndTracks( const std::vector& curves, const std::vector& tracks ); - void updateCurvesAndTracks(); + void analyseCurvesAndTracks( const std::vector& curves, const std::vector& tracks ); + void analyseCurvesAndTracks(); + void applyDataSourceChanges( const std::vector& curves, const std::vector& tracks ); + void applyDataSourceChanges(); void applyPrevCase(); void applyNextCase(); @@ -114,6 +116,10 @@ private: caf::PdmField m_wbsSmoothing; caf::PdmField m_wbsSmoothingThreshold; + caf::PdmField m_rftTimeStep; + caf::PdmField m_rftWellName; + caf::PdmField m_rftSegmentBranchId; + std::set m_uniqueCases; std::set m_uniqueTrajectoryTypes; std::set m_uniqueWellPaths; @@ -123,4 +129,8 @@ private: std::set m_uniqueBranchIndices; std::set m_uniqueWbsSmoothing; std::set m_uniqueWbsSmoothingThreshold; + + std::set m_uniqueRftTimeSteps; + std::set m_uniqueRftWellNames; + std::set m_uniqueRftBranchIds; }; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.cpp index 78460e82dd..7490134a10 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.cpp @@ -41,6 +41,7 @@ #include "RimMainPlotCollection.h" #include "RimObservedFmuRftData.h" #include "RimProject.h" +#include "RimRftTools.h" #include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" #include "RimTools.h" @@ -182,6 +183,14 @@ RimWellLogRftCurve::~RimWellLogRftCurve() { } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogRftCurve::setWellName( const QString& wellName ) +{ + m_wellName = wellName; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -206,6 +215,30 @@ QString RimWellLogRftCurve::wellLogChannelUnits() const return RiaWellLogUnitTools::noUnitString(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogRftCurve::setTimeStep( const QDateTime& dateTime ) +{ + m_timeStep = dateTime; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QDateTime RimWellLogRftCurve::timeStep() const +{ + return m_timeStep(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogRftCurve::setSegmentBranchId( const QString& branchId ) +{ + m_segmentBranchId = branchId; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -466,7 +499,12 @@ void RimWellLogRftCurve::onLoadDataAndUpdate( bool updateParentPlot ) RiaDefines::EclipseUnitSystem unitSystem = RiaDefines::EclipseUnitSystem::UNITS_METRIC; if ( m_eclipseResultCase ) { - unitSystem = m_eclipseResultCase->eclipseCaseData()->unitsType(); + // TODO: If no grid data, but only RFT data is loaded, we do not have any way to + // detect unit + if ( m_eclipseResultCase->eclipseCaseData() ) + { + unitSystem = m_eclipseResultCase->eclipseCaseData()->unitsType(); + } } else if ( m_summaryCase ) { @@ -668,6 +706,7 @@ QList RimWellLogRftCurve::calculateValueOptions( const c if ( !options.empty() ) return options; + RifReaderRftInterface* reader = rftReader(); if ( fieldNeedingOptions == &m_eclipseResultCase ) { RimTools::caseOptionItems( &options ); @@ -676,53 +715,15 @@ QList RimWellLogRftCurve::calculateValueOptions( const c } else if ( fieldNeedingOptions == &m_wellName ) { - options.push_back( caf::PdmOptionItemInfo( "None", "" ) ); - RifReaderRftInterface* reader = rftReader(); - if ( reader ) - { - std::set wellNames = reader->wellNames(); - for ( const QString& name : wellNames ) - { - options.push_back( caf::PdmOptionItemInfo( name, name, false, caf::IconProvider( ":/Well.svg" ) ) ); - } - } + options = RimRftTools::wellNameOptions( reader ); } else if ( fieldNeedingOptions == &m_wellLogChannelName ) { - RifReaderRftInterface* reader = rftReader(); - if ( reader ) - { - for ( const RifEclipseRftAddress::RftWellLogChannelType& channelName : - reader->availableWellLogChannels( m_wellName ) ) - { - options.push_back( - caf::PdmOptionItemInfo( caf::AppEnum::uiText( channelName ), - channelName ) ); - } - } - if ( options.empty() ) - { - options.push_back( caf::PdmOptionItemInfo( caf::AppEnum::uiText( - RifEclipseRftAddress::RftWellLogChannelType::NONE ), - RifEclipseRftAddress::RftWellLogChannelType::NONE ) ); - } + options = RimRftTools::wellLogChannelsOptions( reader, m_wellName() ); } else if ( fieldNeedingOptions == &m_timeStep ) { - RifReaderRftInterface* reader = rftReader(); - if ( reader ) - { - QString dateFormat = "dd MMM yyyy"; - std::set timeStamps = reader->availableTimeSteps( m_wellName, m_wellLogChannelName() ); - for ( const QDateTime& dt : timeStamps ) - { - QString dateString = RiaQDateTimeTools::toStringUsingApplicationLocale( dt, dateFormat ); - - options.push_back( caf::PdmOptionItemInfo( dateString, dt ) ); - } - } - - options.push_back( caf::PdmOptionItemInfo( "None", QDateTime() ) ); + options = RimRftTools::timeStepOptions( reader, m_wellName, m_wellLogChannelName() ); } else if ( fieldNeedingOptions == &m_branchIndex ) { @@ -733,46 +734,11 @@ QList RimWellLogRftCurve::calculateValueOptions( const c } else if ( fieldNeedingOptions == &m_segmentResultName ) { - options.push_front( - caf::PdmOptionItemInfo( RiaResultNames::undefinedResultName(), RiaResultNames::undefinedResultName() ) ); - - RifReaderRftInterface* reader = rftReader(); - if ( reader ) - { - options.push_back( caf::PdmOptionItemInfo( RiaDefines::segmentNumberResultName(), - RiaDefines::segmentNumberResultName() ) ); - - for ( const auto& resultAdr : reader->eclipseRftAddresses( m_wellName(), m_timeStep() ) ) - { - if ( resultAdr.wellLogChannel() == RifEclipseRftAddress::RftWellLogChannelType::SEGMENT_VALUES ) - { - options.push_back( - caf::PdmOptionItemInfo( resultAdr.segmentResultName(), resultAdr.segmentResultName() ) ); - } - } - } + options = RimRftTools::segmentResultNameOptions( reader, m_wellName(), m_timeStep() ); } else if ( fieldNeedingOptions == &m_segmentBranchId ) { - options.push_front( caf::PdmOptionItemInfo( RiaDefines::allBranches(), RiaDefines::allBranches() ) ); - - RifReaderRftInterface* reader = rftReader(); - if ( reader ) - { - std::vector values; - - auto adr = RifEclipseRftAddress::createSegmentResult( m_wellName(), - m_timeStep, - RiaDefines::segmentBranchNumberResultName() ); - - reader->values( adr, &values ); - for ( const auto& v : values ) - { - int intValue = v; - auto txt = QString::number( intValue ); - options.push_back( caf::PdmOptionItemInfo( txt, txt ) ); - } - } + options = RimRftTools::segmentBranchIdOptions( reader, m_wellName(), m_timeStep() ); } return options; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.h index 0bcfbb8f25..9cd38fb196 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.h @@ -67,10 +67,17 @@ public: RimWellLogRftCurve(); ~RimWellLogRftCurve() override; + void setWellName( const QString& wellName ); QString wellName() const override; + QString wellLogChannelUiName() const override; QString wellLogChannelUnits() const override; + void setTimeStep( const QDateTime& dateTime ); + QDateTime timeStep() const; + + void setSegmentBranchId( const QString& branchId ); + void setEclipseResultCase( RimEclipseResultCase* eclipseResultCase ); RimEclipseResultCase* eclipseResultCase() const;