///////////////////////////////////////////////////////////////////////////////// // // 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::segmentBranchIndexOptions( RifReaderRftInterface* readerRft, const QString& wellName, const QDateTime& timeStep ) { QList options; options.push_front( caf::PdmOptionItemInfo( RiaDefines::allBranches(), -1 ) ); if ( readerRft ) { std::vector values; auto adr = RifEclipseRftAddress::createSegmentAddress( wellName, timeStep, RiaDefines::segmentOneBasedBranchIndexResultName() ); readerRft->values( adr, &values ); for ( const auto& v : values ) { int intValue = v; auto txt = QString::number( intValue ); options.push_back( caf::PdmOptionItemInfo( txt, intValue ) ); } } return options; }