2022-01-13 02:02:07 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// 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 <http://www.gnu.org/licenses/gpl.html>
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RimSummaryAddressCollection.h"
|
|
|
|
|
|
|
|
#include "RifEclipseSummaryAddress.h"
|
|
|
|
|
|
|
|
#include "RimSummaryAddress.h"
|
|
|
|
|
|
|
|
#include "cafPdmUiTreeOrdering.h"
|
|
|
|
|
2022-02-16 09:36:50 -06:00
|
|
|
template <>
|
|
|
|
void caf::AppEnum<RimSummaryAddressCollection::CollectionContentType>::setUp()
|
|
|
|
{
|
|
|
|
addItem( RimSummaryAddressCollection::CollectionContentType::NOT_DEFINED, "NOT_DEFINED", "Not Defined" );
|
|
|
|
addItem( RimSummaryAddressCollection::CollectionContentType::WELL, "WELL", "Well" );
|
2022-04-08 03:46:54 -05:00
|
|
|
addItem( RimSummaryAddressCollection::CollectionContentType::GROUP, "GROUP", "Group" );
|
2022-02-16 09:36:50 -06:00
|
|
|
addItem( RimSummaryAddressCollection::CollectionContentType::REGION, "REGION", "Region" );
|
|
|
|
addItem( RimSummaryAddressCollection::CollectionContentType::MISC, "MISC", "Miscellaneous" );
|
|
|
|
addItem( RimSummaryAddressCollection::CollectionContentType::FIELD, "FIELD", "Field" );
|
2022-04-26 18:51:55 -05:00
|
|
|
addItem( RimSummaryAddressCollection::CollectionContentType::BLOCK, "BLOCK", "Block" );
|
2022-02-16 09:36:50 -06:00
|
|
|
setDefault( RimSummaryAddressCollection::CollectionContentType::NOT_DEFINED );
|
|
|
|
}
|
|
|
|
|
2022-01-13 02:02:07 -06:00
|
|
|
CAF_PDM_SOURCE_INIT( RimSummaryAddressCollection, "RimSummaryAddressCollection" );
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimSummaryAddressCollection::RimSummaryAddressCollection()
|
|
|
|
{
|
|
|
|
CAF_PDM_InitObject( "Folder", ":/Folder.png", "", "" );
|
|
|
|
|
2022-02-16 09:36:50 -06:00
|
|
|
CAF_PDM_InitFieldNoDefault( &m_contentType, "ContentsType", "Contents" );
|
|
|
|
m_contentType = RimSummaryAddressCollection::CollectionContentType::NOT_DEFINED;
|
|
|
|
m_contentType.uiCapability()->setUiReadOnly( true );
|
|
|
|
m_contentType.uiCapability()->setUiHidden( true );
|
|
|
|
|
2022-01-13 02:02:07 -06:00
|
|
|
CAF_PDM_InitFieldNoDefault( &m_adresses, "SummaryAddresses", "Addresses" );
|
|
|
|
m_adresses.uiCapability()->setUiTreeHidden( true );
|
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault( &m_subfolders, "AddressSubfolders", "Subfolders" );
|
|
|
|
m_subfolders.uiCapability()->setUiTreeHidden( true );
|
|
|
|
|
2022-02-16 09:36:50 -06:00
|
|
|
CAF_PDM_InitField( &m_caseId, "CaseId", -1, "CaseId" );
|
|
|
|
m_caseId.uiCapability()->setUiHidden( true );
|
|
|
|
|
|
|
|
CAF_PDM_InitField( &m_ensembleId, "EnsembleId", -1, "EnsembleId" );
|
|
|
|
m_ensembleId.uiCapability()->setUiHidden( true );
|
|
|
|
|
2022-01-13 02:02:07 -06:00
|
|
|
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 ) );
|
2022-02-16 09:36:50 -06:00
|
|
|
if ( m_caseId == -1 ) m_caseId = caseId;
|
|
|
|
if ( m_ensembleId == -1 ) m_ensembleId = ensembleId;
|
2022-01-13 02:02:07 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimSummaryAddressCollection::addToSubfolder( QString foldername,
|
2022-02-16 09:36:50 -06:00
|
|
|
CollectionContentType folderType,
|
2022-01-13 02:02:07 -06:00
|
|
|
const RifEclipseSummaryAddress& address,
|
|
|
|
int caseId,
|
|
|
|
int ensembleId )
|
|
|
|
{
|
2022-02-16 09:36:50 -06:00
|
|
|
RimSummaryAddressCollection* folder = getOrCreateSubfolder( foldername, folderType );
|
2022-01-13 02:02:07 -06:00
|
|
|
folder->addAddress( address, caseId, ensembleId );
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimSummaryAddressCollection::updateFolderStructure( const std::set<RifEclipseSummaryAddress>& addresses,
|
|
|
|
int caseId,
|
|
|
|
int ensembleId )
|
|
|
|
{
|
|
|
|
if ( addresses.size() == 0 ) return;
|
|
|
|
|
2022-02-16 09:36:50 -06:00
|
|
|
RimSummaryAddressCollection* misc = getOrCreateSubfolder( "Miscellaneous", CollectionContentType::MISC );
|
|
|
|
RimSummaryAddressCollection* fields = getOrCreateSubfolder( "Field", CollectionContentType::FIELD );
|
2022-03-31 01:57:52 -05:00
|
|
|
RimSummaryAddressCollection* regions = getOrCreateSubfolder( "Regions", CollectionContentType::REGION_FOLDER );
|
|
|
|
RimSummaryAddressCollection* wells = getOrCreateSubfolder( "Wells", CollectionContentType::WELL_FOLDER );
|
2022-04-07 14:06:40 -05:00
|
|
|
RimSummaryAddressCollection* groups = getOrCreateSubfolder( "Groups", CollectionContentType::GROUP_FOLDER );
|
2022-04-26 18:51:55 -05:00
|
|
|
RimSummaryAddressCollection* blocks = getOrCreateSubfolder( "Blocks", CollectionContentType::BLOCK_FOLDER );
|
2022-01-13 02:02:07 -06:00
|
|
|
|
|
|
|
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:
|
2022-02-16 09:36:50 -06:00
|
|
|
regions->addToSubfolder( QString::number( address.regionNumber() ),
|
|
|
|
CollectionContentType::REGION,
|
|
|
|
address,
|
|
|
|
caseId,
|
|
|
|
ensembleId );
|
2022-01-13 02:02:07 -06:00
|
|
|
break;
|
|
|
|
|
2022-04-07 14:06:40 -05:00
|
|
|
case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_GROUP:
|
|
|
|
groups->addToSubfolder( QString::fromStdString( address.groupName() ),
|
2022-04-08 03:46:54 -05:00
|
|
|
CollectionContentType::GROUP,
|
2022-02-16 09:36:50 -06:00
|
|
|
address,
|
|
|
|
caseId,
|
|
|
|
ensembleId );
|
2022-01-13 02:02:07 -06:00
|
|
|
break;
|
|
|
|
|
2022-04-26 18:51:55 -05:00
|
|
|
case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_BLOCK:
|
|
|
|
blocks->addToSubfolder( QString::fromStdString( address.blockAsString() ),
|
|
|
|
CollectionContentType::BLOCK,
|
|
|
|
address,
|
|
|
|
caseId,
|
|
|
|
ensembleId );
|
|
|
|
break;
|
|
|
|
|
2022-01-13 02:02:07 -06:00
|
|
|
case RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL:
|
2022-02-16 09:36:50 -06:00
|
|
|
wells->addToSubfolder( QString::fromStdString( address.wellName() ),
|
|
|
|
CollectionContentType::WELL,
|
|
|
|
address,
|
|
|
|
caseId,
|
|
|
|
ensembleId );
|
2022-01-13 02:02:07 -06:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2022-02-16 09:36:50 -06:00
|
|
|
RimSummaryAddressCollection* RimSummaryAddressCollection::getOrCreateSubfolder( const QString folderName,
|
|
|
|
CollectionContentType createFolderType )
|
2022-01-13 02:02:07 -06:00
|
|
|
{
|
|
|
|
for ( auto& folder : m_subfolders )
|
|
|
|
{
|
|
|
|
if ( folder->name() == folderName )
|
|
|
|
{
|
|
|
|
return folder;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RimSummaryAddressCollection* newFolder = new RimSummaryAddressCollection();
|
|
|
|
newFolder->setName( folderName );
|
2022-02-16 09:36:50 -06:00
|
|
|
newFolder->setContentType( createFolderType );
|
2022-01-13 02:02:07 -06:00
|
|
|
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 ) );
|
|
|
|
}
|
|
|
|
|
2022-02-16 09:36:50 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimSummaryAddressCollection::canBeDragged() const
|
|
|
|
{
|
|
|
|
bool ok = m_subfolders.size() == 0;
|
|
|
|
|
2022-04-08 03:46:54 -05:00
|
|
|
ok = ok && ( m_contentType == CollectionContentType::WELL || m_contentType == CollectionContentType::GROUP ||
|
2022-02-16 09:36:50 -06:00
|
|
|
m_contentType == CollectionContentType::REGION );
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
2022-01-13 02:02:07 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimSummaryAddressCollection::updateUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering ) const
|
|
|
|
{
|
|
|
|
for ( auto& folder : m_subfolders() )
|
|
|
|
{
|
|
|
|
uiTreeOrdering.add( folder );
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( auto& address : m_adresses() )
|
|
|
|
{
|
|
|
|
uiTreeOrdering.add( address );
|
|
|
|
}
|
|
|
|
}
|
2022-02-16 09:36:50 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimSummaryAddressCollection::setContentType( CollectionContentType content )
|
|
|
|
{
|
|
|
|
m_contentType = content;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimSummaryAddressCollection::CollectionContentType RimSummaryAddressCollection::contentType() const
|
|
|
|
{
|
|
|
|
return m_contentType();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimSummaryAddressCollection::setEnsembleId( int ensembleId )
|
|
|
|
{
|
|
|
|
m_ensembleId = ensembleId;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimSummaryAddressCollection::setCaseId( int caseId )
|
|
|
|
{
|
|
|
|
m_caseId = caseId;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimSummaryAddressCollection::isEnsemble() const
|
|
|
|
{
|
|
|
|
return m_ensembleId >= 0;
|
|
|
|
}
|
|
|
|
|
2022-04-28 02:03:40 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimSummaryAddressCollection::isFolder() const
|
|
|
|
{
|
|
|
|
if ( contentType() == CollectionContentType::WELL_FOLDER || contentType() == CollectionContentType::GROUP_FOLDER ||
|
|
|
|
contentType() == CollectionContentType::REGION_FOLDER || contentType() == CollectionContentType::BLOCK_FOLDER )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-02-16 09:36:50 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
int RimSummaryAddressCollection::ensembleId() const
|
|
|
|
{
|
|
|
|
return m_ensembleId;
|
|
|
|
}
|
|
|
|
|
2022-03-31 01:57:52 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<RimSummaryAddressCollection*> RimSummaryAddressCollection::subFolders() const
|
|
|
|
{
|
|
|
|
return m_subfolders.childObjects();
|
|
|
|
}
|
|
|
|
|
2022-02-16 09:36:50 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
int RimSummaryAddressCollection::caseId() const
|
|
|
|
{
|
|
|
|
return m_caseId;
|
|
|
|
}
|