diff --git a/ApplicationExeCode/Resources/DataVector.png b/ApplicationExeCode/Resources/DataVector.png new file mode 100644 index 0000000000..17778a1002 Binary files /dev/null and b/ApplicationExeCode/Resources/DataVector.png differ diff --git a/ApplicationExeCode/Resources/ResInsight.qrc b/ApplicationExeCode/Resources/ResInsight.qrc index 36cf73cb3c..ebd7275464 100644 --- a/ApplicationExeCode/Resources/ResInsight.qrc +++ b/ApplicationExeCode/Resources/ResInsight.qrc @@ -240,6 +240,7 @@ ComboBoxDown.svg ComboBoxUp.svg WellIntAnalysis.png + DataVector.png fs_CellFace.glsl diff --git a/ApplicationLibCode/Commands/RicReloadSummaryCaseFeature.cpp b/ApplicationLibCode/Commands/RicReloadSummaryCaseFeature.cpp index 21918dc2b6..0bdf03d494 100644 --- a/ApplicationLibCode/Commands/RicReloadSummaryCaseFeature.cpp +++ b/ApplicationLibCode/Commands/RicReloadSummaryCaseFeature.cpp @@ -61,6 +61,7 @@ void RicReloadSummaryCaseFeature::onActionTriggered( bool isChecked ) { summaryCase->createSummaryReaderInterface(); summaryCase->createRftReaderInterface(); + summaryCase->refreshMetaData(); RicReplaceSummaryCaseFeature::updateRequredCalculatedCurves( summaryCase ); diff --git a/ApplicationLibCode/Commands/RicReplaceSummaryCaseFeature.cpp b/ApplicationLibCode/Commands/RicReplaceSummaryCaseFeature.cpp index dd39a039a9..6acb769081 100644 --- a/ApplicationLibCode/Commands/RicReplaceSummaryCaseFeature.cpp +++ b/ApplicationLibCode/Commands/RicReplaceSummaryCaseFeature.cpp @@ -92,6 +92,8 @@ void RicReplaceSummaryCaseFeature::onActionTriggered( bool isChecked ) summaryCase->updateAutoShortName(); summaryCase->createSummaryReaderInterface(); summaryCase->createRftReaderInterface(); + summaryCase->refreshMetaData(); + RiaLogging::info( QString( "Replaced summary data for %1" ).arg( oldSummaryHeaderFilename ) ); RicReplaceSummaryCaseFeature::updateRequredCalculatedCurves( summaryCase ); diff --git a/ApplicationLibCode/ProjectDataModel/RimMainPlotCollection.cpp b/ApplicationLibCode/ProjectDataModel/RimMainPlotCollection.cpp index 33959f1883..503979b3c9 100644 --- a/ApplicationLibCode/ProjectDataModel/RimMainPlotCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimMainPlotCollection.cpp @@ -347,7 +347,7 @@ void RimMainPlotCollection::ensureCalculationIdsAreAssigned() for ( RimSummaryAddress* adr : allAddresses ) { - adr->ensureIdIsAssigned(); + adr->ensureCalculationIdIsAssigned(); } } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/Summary/CMakeLists_files.cmake index c5b3d836f9..ea3b2fff7b 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/Summary/CMakeLists_files.cmake @@ -41,6 +41,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimSummaryDataSourceStepping.h ${CMAKE_CURRENT_LIST_DIR}/RimSummaryNameHelper.h ${CMAKE_CURRENT_LIST_DIR}/RimMultipleSummaryPlotNameHelper.h + ${CMAKE_CURRENT_LIST_DIR}/RimSummaryAddressCollection.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -86,6 +87,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimSummaryDataSourceStepping.cpp ${CMAKE_CURRENT_LIST_DIR}/RimSummaryNameHelper.cpp ${CMAKE_CURRENT_LIST_DIR}/RimMultipleSummaryPlotNameHelper.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimSummaryAddressCollection.cpp ) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddress.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddress.cpp index cea2e0e94a..932e938aea 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddress.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddress.cpp @@ -58,6 +58,8 @@ CAF_PDM_SOURCE_INIT( RimSummaryAddress, "SummaryAddress" ); //-------------------------------------------------------------------------------------------------- RimSummaryAddress::RimSummaryAddress() { + CAF_PDM_InitObject( "SummaryAddress", ":/DataVector.png", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_category, "SummaryVarType", "Type" ); CAF_PDM_InitFieldNoDefault( &m_quantityName, "SummaryQuantityName", "Quantity" ); CAF_PDM_InitFieldNoDefault( &m_regionNumber, "SummaryRegion", "Region" ); @@ -73,6 +75,9 @@ RimSummaryAddress::RimSummaryAddress() CAF_PDM_InitFieldNoDefault( &m_isErrorResult, "IsErrorResult", "Is Error Result" ); CAF_PDM_InitFieldNoDefault( &m_calculationId, "CalculationId", "Calculation Id" ); + CAF_PDM_InitField( &m_caseId, "CaseId", -1, "CaseId" ); + CAF_PDM_InitField( &m_ensembleId, "EnsembleId", -1, "EnsembleId" ); + m_category = RifEclipseSummaryAddress::SUMMARY_INVALID; m_regionNumber = -1; m_regionNumber2 = -1; @@ -92,6 +97,20 @@ RimSummaryAddress::~RimSummaryAddress() { } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryAddress* RimSummaryAddress::wrapFileReaderAddress( const RifEclipseSummaryAddress& addr, + int caseId /* = -1 */, + int ensembleId /* = -1 */ ) +{ + RimSummaryAddress* newAddress = new RimSummaryAddress(); + newAddress->setAddress( addr ); + newAddress->setCaseId( caseId ); + newAddress->setEnsembleId( ensembleId ); + return newAddress; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -112,6 +131,8 @@ void RimSummaryAddress::setAddress( const RifEclipseSummaryAddress& addr ) m_cellJ = addr.cellJ(); m_cellK = addr.cellK(); m_calculationId = addr.id(); + + setUiName( m_quantityName ); } //-------------------------------------------------------------------------------------------------- @@ -138,7 +159,7 @@ RifEclipseSummaryAddress RimSummaryAddress::address() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryAddress::ensureIdIsAssigned() +void RimSummaryAddress::ensureCalculationIdIsAssigned() { if ( m_category == RifEclipseSummaryAddress::SUMMARY_CALCULATED && m_calculationId == -1 ) { @@ -176,3 +197,59 @@ RiaDefines::PhaseType RimSummaryAddress::addressPhaseType() const } return RiaDefines::PhaseType::PHASE_NOT_APPLICABLE; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryAddress::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + uiOrdering.skipRemainingFields( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryAddress::setCaseId( int caseId ) +{ + m_caseId = caseId; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimSummaryAddress::caseId() const +{ + return m_caseId; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimSummaryAddress::quantityName() const +{ + return m_quantityName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryAddress::setEnsembleId( int ensembleId ) +{ + m_ensembleId = ensembleId; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimSummaryAddress::ensembleId() const +{ + return m_ensembleId; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryAddress::isEnsemble() const +{ + return m_ensembleId >= 0; +} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddress.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddress.h index 7b54ba07ae..5a1fb208d3 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddress.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddress.h @@ -44,26 +44,44 @@ public: RimSummaryAddress(); ~RimSummaryAddress() override; + static RimSummaryAddress* + wrapFileReaderAddress( const RifEclipseSummaryAddress& addr, int caseId = -1, int ensembleId = -1 ); + void setAddress( const RifEclipseSummaryAddress& addr ); RifEclipseSummaryAddress address(); - void ensureIdIsAssigned(); + void setCaseId( int caseId ); + int caseId() const; + + void setEnsembleId( int ensembleId ); + int ensembleId() const; + bool isEnsemble() const; + + QString quantityName() const; + + void ensureCalculationIdIsAssigned(); RiaDefines::PhaseType addressPhaseType() const; +protected: + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + private: caf::PdmField> m_category; - caf::PdmField m_quantityName; - caf::PdmField m_regionNumber; - caf::PdmField m_regionNumber2; - caf::PdmField m_wellGroupName; - caf::PdmField m_wellName; - caf::PdmField m_wellSegmentNumber; - caf::PdmField m_lgrName; - caf::PdmField m_cellI; - caf::PdmField m_cellJ; - caf::PdmField m_cellK; - caf::PdmField m_aquiferNumber; - caf::PdmField m_isErrorResult; - caf::PdmField m_calculationId; + + caf::PdmField m_quantityName; + caf::PdmField m_regionNumber; + caf::PdmField m_regionNumber2; + caf::PdmField m_wellGroupName; + caf::PdmField m_wellName; + caf::PdmField m_wellSegmentNumber; + caf::PdmField m_lgrName; + caf::PdmField m_cellI; + caf::PdmField m_cellJ; + caf::PdmField m_cellK; + caf::PdmField m_aquiferNumber; + caf::PdmField m_isErrorResult; + caf::PdmField m_calculationId; + caf::PdmField m_caseId; + caf::PdmField m_ensembleId; }; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.cpp new file mode 100644 index 0000000000..5be61624a9 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.cpp @@ -0,0 +1,190 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RimSummaryAddressCollection.h" + +#include "RifEclipseSummaryAddress.h" + +#include "RimSummaryAddress.h" + +#include "cafPdmUiTreeOrdering.h" + +CAF_PDM_SOURCE_INIT( RimSummaryAddressCollection, "RimSummaryAddressCollection" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryAddressCollection::RimSummaryAddressCollection() +{ + CAF_PDM_InitObject( "Folder", ":/Folder.png", "", "" ); + + CAF_PDM_InitFieldNoDefault( &m_adresses, "SummaryAddresses", "Addresses" ); + m_adresses.uiCapability()->setUiTreeHidden( true ); + + CAF_PDM_InitFieldNoDefault( &m_subfolders, "AddressSubfolders", "Subfolders" ); + m_subfolders.uiCapability()->setUiTreeHidden( true ); + + nameField()->uiCapability()->setUiHidden( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryAddressCollection::~RimSummaryAddressCollection() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryAddressCollection::hasDataVector( const QString quantityName ) const +{ + for ( auto& address : m_adresses ) + { + if ( address->quantityName() == quantityName ) return true; + } + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryAddressCollection::hasDataVector( const std::string quantityName ) const +{ + return hasDataVector( QString::fromStdString( quantityName ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryAddressCollection::addAddress( const RifEclipseSummaryAddress& address, int caseId, int ensembleId ) +{ + if ( !hasDataVector( address.quantityName() ) ) + { + m_adresses.push_back( RimSummaryAddress::wrapFileReaderAddress( address, caseId, ensembleId ) ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryAddressCollection::addToSubfolder( QString foldername, + const RifEclipseSummaryAddress& address, + int caseId, + int ensembleId ) +{ + RimSummaryAddressCollection* folder = getOrCreateSubfolder( foldername ); + folder->addAddress( address, caseId, ensembleId ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryAddressCollection::updateFolderStructure( const std::set& addresses, + int caseId, + int ensembleId ) +{ + if ( addresses.size() == 0 ) return; + + RimSummaryAddressCollection* misc = getOrCreateSubfolder( "Miscellaneous" ); + RimSummaryAddressCollection* fields = getOrCreateSubfolder( "Field" ); + RimSummaryAddressCollection* regions = getOrCreateSubfolder( "Regions" ); + RimSummaryAddressCollection* wells = getOrCreateSubfolder( "Wells" ); + RimSummaryAddressCollection* groups = getOrCreateSubfolder( "Groups" ); + + for ( const auto& address : addresses ) + { + switch ( address.category() ) + { + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_MISC: + misc->addAddress( address, caseId, ensembleId ); + break; + + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_FIELD: + fields->addAddress( address, caseId, ensembleId ); + break; + + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_REGION: + regions->addToSubfolder( QString::number( address.regionNumber() ), address, caseId, ensembleId ); + break; + + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_GROUP: + groups->addToSubfolder( QString::fromStdString( address.wellGroupName() ), address, caseId, ensembleId ); + break; + + case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL: + wells->addToSubfolder( QString::fromStdString( address.wellName() ), address, caseId, ensembleId ); + break; + + default: + continue; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryAddressCollection* RimSummaryAddressCollection::getOrCreateSubfolder( const QString folderName ) +{ + for ( auto& folder : m_subfolders ) + { + if ( folder->name() == folderName ) + { + return folder; + } + } + + RimSummaryAddressCollection* newFolder = new RimSummaryAddressCollection(); + newFolder->setName( folderName ); + m_subfolders.push_back( newFolder ); + return newFolder; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryAddressCollection::clear() +{ + m_adresses.clear(); + m_subfolders.clear(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryAddressCollection::isEmpty() const +{ + return ( ( m_adresses.size() == 0 ) && ( m_subfolders.size() == 0 ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryAddressCollection::updateUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering ) const +{ + for ( auto& folder : m_subfolders() ) + { + uiTreeOrdering.add( folder ); + } + + for ( auto& address : m_adresses() ) + { + uiTreeOrdering.add( address ); + } +} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.h new file mode 100644 index 0000000000..c4f2619b40 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryAddressCollection.h @@ -0,0 +1,59 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RimNamedObject.h" + +#include "cafPdmChildArrayField.h" + +#include +#include +#include + +class RimSummaryAddress; +class RifEclipseSummaryAddress; + +class RimSummaryAddressCollection : public RimNamedObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimSummaryAddressCollection(); + ~RimSummaryAddressCollection() override; + + void updateFolderStructure( const std::set& addresses, int caseid, int ensembleId = -1 ); + + void clear(); + + bool isEmpty() const; + + void updateUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering ) const; + +private: + RimSummaryAddressCollection* getOrCreateSubfolder( const QString folderName ); + + bool hasDataVector( const QString quantityName ) const; + bool hasDataVector( const std::string quantityName ) const; + + void addAddress( const RifEclipseSummaryAddress& address, int caseId, int ensembleId = -1 ); + void addToSubfolder( QString foldername, const RifEclipseSummaryAddress& address, int caseId, int ensembleId = -1 ); + +private: + caf::PdmChildArrayField m_adresses; + caf::PdmChildArrayField m_subfolders; +}; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.cpp index 86f3e451a6..d715f50ad1 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.cpp @@ -24,12 +24,17 @@ #include "RicfCommandObject.h" #include "RifSummaryReaderInterface.h" +#include "RifEclipseSummaryAddress.h" + #include "RimMainPlotCollection.h" #include "RimProject.h" +#include "RimSummaryAddress.h" +#include "RimSummaryAddressCollection.h" #include "RimSummaryCaseCollection.h" #include "RimSummaryPlotCollection.h" #include "cafPdmFieldScriptingCapability.h" +#include "cafPdmUiTreeOrdering.h" #include "cvfAssert.h" @@ -62,6 +67,11 @@ RimSummaryCase::RimSummaryCase() m_caseId.uiCapability()->setUiReadOnly( true ); m_caseId.capability()->setIOWriteable( false ); + CAF_PDM_InitFieldNoDefault( &m_dataVectorFolders, "DataVectorFolders", "Data Folders" ); + m_dataVectorFolders = new RimSummaryAddressCollection(); + m_dataVectorFolders.uiCapability()->setUiHidden( true ); + m_dataVectorFolders.xmlCapability()->disableIO(); + m_isObservedData = false; } @@ -200,11 +210,32 @@ QString RimSummaryCase::errorMessagesFromReader() return QString(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCase::buildChildNodes() +{ + m_dataVectorFolders->clear(); + + RifSummaryReaderInterface* reader = summaryReader(); + if ( !reader ) return; + + m_dataVectorFolders->updateFolderStructure( reader->allResultAddresses(), m_caseId ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimSummaryCase::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/ ) { + if ( !ensemble() ) + { + if ( m_dataVectorFolders->isEmpty() ) buildChildNodes(); + m_dataVectorFolders->updateUiTreeOrdering( uiTreeOrdering ); + } + + uiTreeOrdering.skipRemainingChildren( true ); + updateTreeItemName(); } @@ -269,6 +300,8 @@ void RimSummaryCase::initAfterRead() } updateOptionSensitivity(); + + refreshMetaData(); } //-------------------------------------------------------------------------------------------------- @@ -361,3 +394,12 @@ int RimSummaryCase::caseId() const { return m_caseId(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCase::refreshMetaData() +{ + buildChildNodes(); + updateConnectedEditors(); +} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.h index 999d30a4ee..a87b9352cb 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCase.h @@ -23,6 +23,8 @@ #include "RimCaseDisplayNameTools.h" #include "cafFilePath.h" +#include "cafPdmChildArrayField.h" +#include "cafPdmChildField.h" #include "cafPdmField.h" #include "cafPdmObject.h" @@ -31,6 +33,7 @@ class RifReaderRftInterface; class RifSummaryReaderInterface; class RimSummaryCaseCollection; +class RimSummaryAddressCollection; //================================================================================================== // @@ -63,6 +66,8 @@ public: void updateAutoShortName(); void updateOptionSensitivity(); + void refreshMetaData(); + virtual void createSummaryReaderInterface() = 0; virtual void createRftReaderInterface() {} virtual RifSummaryReaderInterface* summaryReader() = 0; @@ -93,11 +98,15 @@ private: static QString uniqueShortNameForEnsembleCase( RimSummaryCase* summaryCase ); static QString uniqueShortNameForSummaryCase( RimSummaryCase* summaryCase ); + void buildChildNodes(); + protected: caf::PdmField m_displayName; caf::PdmField m_displayNameOption; caf::PdmField m_summaryHeaderFilename; + caf::PdmChildField m_dataVectorFolders; + bool m_isObservedData; caf::PdmField m_caseId; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp index af8a74a258..3c361f6f38 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp @@ -31,6 +31,7 @@ #include "RimEnsembleCurveSet.h" #include "RimGridSummaryCase.h" #include "RimProject.h" +#include "RimSummaryAddressCollection.h" #include "RimSummaryCase.h" #include "RifReaderEclipseRft.h" @@ -38,6 +39,7 @@ #include "RifSummaryReaderInterface.h" #include "cafPdmFieldScriptingCapability.h" +#include "cafPdmUiTreeOrdering.h" #include @@ -124,6 +126,13 @@ RimSummaryCaseCollection::RimSummaryCaseCollection() m_ensembleId.uiCapability()->setUiReadOnly( true ); m_ensembleId.capability()->setIOWriteable( false ); + CAF_PDM_InitFieldNoDefault( &m_dataVectorFolders, "DataVectorFolders", "Data Folders" ); + m_dataVectorFolders = new RimSummaryAddressCollection(); + m_dataVectorFolders.uiCapability()->setUiHidden( true ); + m_dataVectorFolders.uiCapability()->setUiTreeHidden( true ); + m_dataVectorFolders->uiCapability()->setUiTreeHidden( true ); + m_dataVectorFolders.xmlCapability()->disableIO(); + m_statisticsEclipseRftReader = new RifReaderEnsembleStatisticsRft( this ); m_commonAddressCount = 0; @@ -158,6 +167,8 @@ void RimSummaryCaseCollection::removeCase( RimSummaryCase* summaryCase ) if ( dynamic_cast( summaryCase ) == nullptr ) calculateEnsembleParametersIntersectionHash(); } + + buildChildNodes(); } //-------------------------------------------------------------------------------------------------- @@ -188,6 +199,8 @@ void RimSummaryCaseCollection::addCase( RimSummaryCase* summaryCase ) } updateReferringCurveSets(); + + buildChildNodes(); } //-------------------------------------------------------------------------------------------------- @@ -237,6 +250,8 @@ void RimSummaryCaseCollection::setAsEnsemble( bool isEnsemble ) validateEnsembleCases( allSummaryCases() ); calculateEnsembleParametersIntersectionHash(); } + + refreshMetaData(); } } @@ -872,7 +887,11 @@ caf::PdmFieldHandle* RimSummaryCaseCollection::userDescriptionField() //-------------------------------------------------------------------------------------------------- void RimSummaryCaseCollection::onLoadDataAndUpdate() { - if ( m_isEnsemble ) calculateEnsembleParametersIntersectionHash(); + if ( m_isEnsemble ) + { + calculateEnsembleParametersIntersectionHash(); + buildChildNodes(); + } } //-------------------------------------------------------------------------------------------------- @@ -933,6 +952,8 @@ void RimSummaryCaseCollection::initAfterRead() } updateIcon(); + + buildChildNodes(); } //-------------------------------------------------------------------------------------------------- @@ -969,6 +990,30 @@ void RimSummaryCaseCollection::defineUiOrdering( QString uiConfigName, caf::PdmU uiOrdering.skipRemainingFields( true ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseCollection::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, + QString uiConfigName /*= ""*/ ) +{ + if ( m_isEnsemble() ) + { + if ( m_dataVectorFolders->isEmpty() ) + { + buildChildNodes(); + } + m_dataVectorFolders->updateUiTreeOrdering( uiTreeOrdering ); + + auto subnode = uiTreeOrdering.add( "Realizations", ":/Folder.png" ); + for ( auto& smcase : m_cases ) + { + subnode->add( smcase ); + } + + uiTreeOrdering.skipRemainingChildren( true ); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1008,3 +1053,27 @@ bool RimSummaryCaseCollection::hasEnsembleParameters() const return false; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseCollection::buildChildNodes() +{ + m_dataVectorFolders->clear(); + + for ( auto& smcase : m_cases ) + { + m_dataVectorFolders->updateFolderStructure( smcase->summaryReader()->allResultAddresses(), + smcase->caseId(), + m_ensembleId ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseCollection::refreshMetaData() +{ + buildChildNodes(); + updateConnectedEditors(); +} diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h index d5c389cfcc..394050c9e3 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h @@ -28,6 +28,7 @@ #include "RimObjectiveFunction.h" #include "cafPdmChildArrayField.h" +#include "cafPdmChildField.h" #include "cafPdmField.h" #include "cafPdmObject.h" #include "cafPdmProxyValueField.h" @@ -40,6 +41,7 @@ class RifReaderRftInterface; class RifReaderEnsembleStatisticsRft; class RimSummaryCase; +class RimSummaryAddressCollection; //================================================================================================== /// @@ -100,6 +102,8 @@ public: RiaDefines::EclipseUnitSystem unitSystem() const; + void refreshMetaData(); + private: RigEnsembleParameter createEnsembleParameter( const QString& paramName ) const; static void sortByBinnedVariation( std::vector& parameterVector ); @@ -114,18 +118,22 @@ private: void onCaseNameChanged( const SignalEmitter* emitter ); + void buildChildNodes(); + protected: virtual void onLoadDataAndUpdate(); void updateReferringCurveSets(); void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; void setNameAsReadOnly(); caf::PdmChildArrayField m_cases; private: - caf::PdmField m_name; - caf::PdmProxyValueField m_nameAndItemCount; - caf::PdmField m_isEnsemble; + caf::PdmField m_name; + caf::PdmProxyValueField m_nameAndItemCount; + caf::PdmField m_isEnsemble; + caf::PdmChildField m_dataVectorFolders; cvf::ref m_statisticsEclipseRftReader; caf::PdmField m_ensembleId; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp index c35ae80254..dd13a74e2a 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp @@ -628,6 +628,7 @@ std::vector RimSummaryCaseMainCollection::createSummaryCasesFro newSumCase->setAssociatedEclipseCase( eclCase ); newSumCase->updateOptionSensitivity(); project->assignCaseIdToSummaryCase( newSumCase ); + newSumCase->refreshMetaData(); sumCases.push_back( newSumCase ); } else @@ -644,6 +645,7 @@ std::vector RimSummaryCaseMainCollection::createSummaryCasesFro newSumCase->setSummaryHeaderFileName( fileInfo.summaryFileName() ); newSumCase->updateOptionSensitivity(); project->assignCaseIdToSummaryCase( newSumCase ); + newSumCase->refreshMetaData(); sumCases.push_back( newSumCase ); } diff --git a/ApplicationLibCode/UserInterface/RiuDragDrop.cpp b/ApplicationLibCode/UserInterface/RiuDragDrop.cpp index 88bd676b81..999d8002c1 100644 --- a/ApplicationLibCode/UserInterface/RiuDragDrop.cpp +++ b/ApplicationLibCode/UserInterface/RiuDragDrop.cpp @@ -33,6 +33,7 @@ #include "RimMimeData.h" #include "RimMultiPlot.h" #include "RimPlot.h" +#include "RimSummaryAddress.h" #include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" @@ -230,7 +231,7 @@ Qt::ItemFlags RiuDragDrop::flags( const QModelIndex& index ) const if ( dynamic_cast( uiItem ) || dynamic_cast( uiItem ) || dynamic_cast( uiItem ) || dynamic_cast( uiItem ) || dynamic_cast( uiItem ) || dynamic_cast( uiItem ) || - dynamic_cast( uiItem ) ) + dynamic_cast( uiItem ) || dynamic_cast( uiItem ) ) { // TODO: Remember to handle reservoir holding the main grid itemflags |= Qt::ItemIsDragEnabled;