From d3ce7a2096182b564d2948f70640b723b27df0d3 Mon Sep 17 00:00:00 2001 From: jonjenssen <69144954+jonjenssen@users.noreply.github.com> Date: Tue, 3 May 2022 16:29:55 +0200 Subject: [PATCH] Add support for all summary data types in data sources tree (#8873) * Add support for all summary data types in data sources tree * Use item icons for folders. --- .../RifEclipseSummaryAddress.cpp | 5 + .../Summary/RimSummaryAddressCollection.cpp | 227 ++++++++++++++++-- .../Summary/RimSummaryAddressCollection.h | 21 +- 3 files changed, 227 insertions(+), 26 deletions(-) diff --git a/ApplicationLibCode/FileInterface/RifEclipseSummaryAddress.cpp b/ApplicationLibCode/FileInterface/RifEclipseSummaryAddress.cpp index b9131c52ca..f78ed769f0 100644 --- a/ApplicationLibCode/FileInterface/RifEclipseSummaryAddress.cpp +++ b/ApplicationLibCode/FileInterface/RifEclipseSummaryAddress.cpp @@ -565,6 +565,11 @@ std::string RifEclipseSummaryAddress::itemUiText() const text += std::to_string( this->id() ); } break; + case SUMMARY_IMPORTED: + { + text += this->quantityName(); + } + break; } return text; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.cpp index f52871587a..73160217bf 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.cpp @@ -28,12 +28,24 @@ template <> void caf::AppEnum::setUp() { addItem( RimSummaryAddressCollection::CollectionContentType::NOT_DEFINED, "NOT_DEFINED", "Not Defined" ); - addItem( RimSummaryAddressCollection::CollectionContentType::WELL, "WELL", "Well" ); - addItem( RimSummaryAddressCollection::CollectionContentType::GROUP, "GROUP", "Group" ); - addItem( RimSummaryAddressCollection::CollectionContentType::REGION, "REGION", "Region" ); - addItem( RimSummaryAddressCollection::CollectionContentType::MISC, "MISC", "Miscellaneous" ); addItem( RimSummaryAddressCollection::CollectionContentType::FIELD, "FIELD", "Field" ); + addItem( RimSummaryAddressCollection::CollectionContentType::AQUIFER, "AQUIFER", "Aquifer" ); + addItem( RimSummaryAddressCollection::CollectionContentType::NETWORK, "NETWORK", "Network" ); + addItem( RimSummaryAddressCollection::CollectionContentType::MISC, "MISC", "Miscellaneous" ); + addItem( RimSummaryAddressCollection::CollectionContentType::REGION, "REGION", "Region" ); + addItem( RimSummaryAddressCollection::CollectionContentType::REGION_2_REGION, "REGION_2_REGION", "Region-Region" ); + addItem( RimSummaryAddressCollection::CollectionContentType::GROUP, "GROUP", "Group" ); + addItem( RimSummaryAddressCollection::CollectionContentType::WELL, "WELL", "Well" ); + addItem( RimSummaryAddressCollection::CollectionContentType::WELL_COMPLETION, "WELL_COMPLETION", "Completion" ); + addItem( RimSummaryAddressCollection::CollectionContentType::WELL_SEGMENT, "WELL_SEGMENT", "Segment" ); addItem( RimSummaryAddressCollection::CollectionContentType::BLOCK, "BLOCK", "Block" ); + addItem( RimSummaryAddressCollection::CollectionContentType::WELL_LGR, "WELL_LGR", "Lgr-Well" ); + addItem( RimSummaryAddressCollection::CollectionContentType::WELL_COMPLETION_LGR, + "WELL_COMPLETION_LGR", + "Lgr Completion" ); + addItem( RimSummaryAddressCollection::CollectionContentType::BLOCK_LGR, "BLOCK_LGR", "Lgr-Block" ); + addItem( RimSummaryAddressCollection::CollectionContentType::CALCULATED, "CALCULATED", "Calculated" ); + addItem( RimSummaryAddressCollection::CollectionContentType::IMPORTED, "IMPORTED", "Imported" ); setDefault( RimSummaryAddressCollection::CollectionContentType::NOT_DEFINED ); } @@ -64,6 +76,8 @@ RimSummaryAddressCollection::RimSummaryAddressCollection() m_ensembleId.uiCapability()->setUiHidden( true ); nameField()->uiCapability()->setUiHidden( true ); + + setUiIconFromResourceString( iconResourceText() ); } //-------------------------------------------------------------------------------------------------- @@ -119,6 +133,24 @@ void RimSummaryAddressCollection::addToSubfolder( QString folder->addAddress( address, caseId, ensembleId ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryAddressCollection::addToSubfolderTree( std::vector folders, + CollectionContentType folderType, + const RifEclipseSummaryAddress& address, + int caseId, + int ensembleId ) +{ + RimSummaryAddressCollection* thefolder = this; + for ( auto& subfoldername : folders ) + { + thefolder = thefolder->getOrCreateSubfolder( subfoldername, folderType ); + } + thefolder->setContentType( folderType ); + thefolder->addAddress( address, caseId, ensembleId ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -128,25 +160,47 @@ void RimSummaryAddressCollection::updateFolderStructure( const std::setaddAddress( address, caseId, ensembleId ); - break; - case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_FIELD: fields->addAddress( address, caseId, ensembleId ); break; + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_AQUIFER: + aquifer->addToSubfolder( QString::number( address.aquiferNumber() ), + CollectionContentType::AQUIFER, + address, + caseId, + ensembleId ); + break; + + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_NETWORK: + network->addAddress( address, caseId, ensembleId ); + break; + + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_MISC: + misc->addAddress( address, caseId, ensembleId ); + break; + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_REGION: regions->addToSubfolder( QString::number( address.regionNumber() ), CollectionContentType::REGION, @@ -155,6 +209,14 @@ void RimSummaryAddressCollection::updateFolderStructure( const std::setaddToSubfolder( QString::fromStdString( address.itemUiText() ), + CollectionContentType::REGION_2_REGION, + address, + caseId, + ensembleId ); + break; + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_GROUP: groups->addToSubfolder( QString::fromStdString( address.groupName() ), CollectionContentType::GROUP, @@ -163,14 +225,6 @@ void RimSummaryAddressCollection::updateFolderStructure( const std::setaddToSubfolder( QString::fromStdString( address.blockAsString() ), - CollectionContentType::BLOCK, - address, - caseId, - ensembleId ); - break; - case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL: wells->addToSubfolder( QString::fromStdString( address.wellName() ), CollectionContentType::WELL, @@ -179,6 +233,76 @@ void RimSummaryAddressCollection::updateFolderStructure( const std::setaddToSubfolderTree( { QString::fromStdString( address.wellName() ), + QString::fromStdString( address.blockAsString() ) }, + CollectionContentType::WELL_COMPLETION, + address, + caseId, + ensembleId ); + break; + + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_SEGMENT: + segment->addToSubfolderTree( { QString::fromStdString( address.wellName() ), + QString::number( address.wellSegmentNumber() ) }, + CollectionContentType::WELL_SEGMENT, + address, + caseId, + ensembleId ); + break; + + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_BLOCK: + blocks->addToSubfolder( QString::fromStdString( address.blockAsString() ), + CollectionContentType::BLOCK, + address, + caseId, + ensembleId ); + break; + + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_LGR: + lgrwell->addToSubfolderTree( { QString::fromStdString( address.lgrName() ), + QString::fromStdString( address.wellName() ) }, + CollectionContentType::WELL_LGR, + address, + caseId, + ensembleId ); + break; + + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_COMPLETION_LGR: + lgrcompletion->addToSubfolderTree( { QString::fromStdString( address.lgrName() ), + QString::fromStdString( address.wellName() ), + QString::fromStdString( address.blockAsString() ) }, + CollectionContentType::WELL_COMPLETION_LGR, + address, + caseId, + ensembleId ); + break; + + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_BLOCK_LGR: + lgrblock->addToSubfolderTree( { QString::fromStdString( address.lgrName() ), + QString::fromStdString( address.blockAsString() ) }, + CollectionContentType::BLOCK_LGR, + address, + caseId, + ensembleId ); + break; + + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_IMPORTED: + imported->addToSubfolder( QString::fromStdString( address.itemUiText() ), + CollectionContentType::IMPORTED, + address, + caseId, + ensembleId ); + break; + + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_CALCULATED: + calculated->addToSubfolder( QString::fromStdString( address.itemUiText() ), + CollectionContentType::CALCULATED, + address, + caseId, + ensembleId ); + break; + default: continue; } @@ -243,7 +367,7 @@ void RimSummaryAddressCollection::updateUiTreeOrdering( caf::PdmUiTreeOrdering& { for ( auto& folder : m_subfolders() ) { - uiTreeOrdering.add( folder ); + if ( !folder->isEmpty() ) uiTreeOrdering.add( folder ); } for ( auto& address : m_adresses() ) @@ -258,6 +382,7 @@ void RimSummaryAddressCollection::updateUiTreeOrdering( caf::PdmUiTreeOrdering& void RimSummaryAddressCollection::setContentType( CollectionContentType content ) { m_contentType = content; + setUiIconFromResourceString( iconResourceText() ); } //-------------------------------------------------------------------------------------------------- @@ -298,7 +423,7 @@ bool RimSummaryAddressCollection::isEnsemble() const bool RimSummaryAddressCollection::isFolder() const { if ( contentType() == CollectionContentType::WELL_FOLDER || contentType() == CollectionContentType::GROUP_FOLDER || - contentType() == CollectionContentType::REGION_FOLDER || contentType() == CollectionContentType::BLOCK_FOLDER ) + contentType() == CollectionContentType::REGION_FOLDER ) { return true; } @@ -329,3 +454,57 @@ int RimSummaryAddressCollection::caseId() const { return m_caseId; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimSummaryAddressCollection::iconResourceText() const +{ + switch ( m_contentType() ) + { + case RimSummaryAddressCollection::CollectionContentType::WELL: + return ":/summary/components/images/well.svg"; + case RimSummaryAddressCollection::CollectionContentType::GROUP: + return ":/summary/components/images/group.svg"; + case RimSummaryAddressCollection::CollectionContentType::REGION: + return ":/summary/components/images/region.svg"; + case RimSummaryAddressCollection::CollectionContentType::FIELD: + return ":/summary/components/images/field.svg"; + case RimSummaryAddressCollection::CollectionContentType::MISC: + return ":/summary/components/images/misc.svg"; + case RimSummaryAddressCollection::CollectionContentType::WELL_FOLDER: + return ":/summary/components/images/well.svg"; + case RimSummaryAddressCollection::CollectionContentType::GROUP_FOLDER: + return ":/summary/components/images/group.svg"; + case RimSummaryAddressCollection::CollectionContentType::REGION_FOLDER: + return ":/summary/components/images/region.svg"; + case RimSummaryAddressCollection::CollectionContentType::BLOCK: + return ":/summary/components/images/block.svg"; + case RimSummaryAddressCollection::CollectionContentType::SUMMARY_CASE: + return ":/SummaryCase.svg"; + case RimSummaryAddressCollection::CollectionContentType::AQUIFER: + return ":/summary/components/images/aquifer.svg"; + case RimSummaryAddressCollection::CollectionContentType::NETWORK: + return ":/summary/components/images/network.svg"; + case RimSummaryAddressCollection::CollectionContentType::REGION_2_REGION: + return ":/summary/components/images/region-region.svg"; + case RimSummaryAddressCollection::CollectionContentType::WELL_COMPLETION: + return ":/summary/components/images/well-completion.svg"; + case RimSummaryAddressCollection::CollectionContentType::WELL_LGR: + return ":/summary/components/images/well.svg"; + case RimSummaryAddressCollection::CollectionContentType::WELL_COMPLETION_LGR: + return ":/summary/components/images/well-completion.svg"; + case RimSummaryAddressCollection::CollectionContentType::WELL_SEGMENT: + return ":/summary/components/images/segment.svg"; + case RimSummaryAddressCollection::CollectionContentType::BLOCK_LGR: + return ":/summary/components/images/block.svg"; + case RimSummaryAddressCollection::CollectionContentType::CALCULATED: + return ":/summary/components/images/calculated.svg"; + case RimSummaryAddressCollection::CollectionContentType::IMPORTED: + return ":/summary/components/images/others.svg"; + case RimSummaryAddressCollection::CollectionContentType::NOT_DEFINED: + default: + break; + } + return ":/Folder.png"; +} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.h index e875e1bb50..29f0b14111 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.h @@ -45,8 +45,17 @@ public: GROUP_FOLDER, REGION_FOLDER, BLOCK, - BLOCK_FOLDER, - SUMMARY_CASE + SUMMARY_CASE, + AQUIFER, + NETWORK, + REGION_2_REGION, + WELL_COMPLETION, + WELL_LGR, + WELL_COMPLETION_LGR, + WELL_SEGMENT, + BLOCK_LGR, + CALCULATED, + IMPORTED }; public: @@ -90,6 +99,14 @@ private: int caseId, int ensembleId = -1 ); + void addToSubfolderTree( std::vector folders, + CollectionContentType folderType, + const RifEclipseSummaryAddress& address, + int caseId, + int ensembleId = -1 ); + + QString iconResourceText() const; + private: caf::PdmChildArrayField m_adresses; caf::PdmChildArrayField m_subfolders;