2024-05-03 09:58:55 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2024 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 "RimVfpDeck.h"
|
|
|
|
|
|
2024-05-13 08:54:40 +02:00
|
|
|
#include "RigVfpTables.h"
|
2024-05-03 09:58:55 +02:00
|
|
|
|
2024-05-13 08:54:40 +02:00
|
|
|
#include "RimVfpDataCollection.h"
|
2024-05-03 09:58:55 +02:00
|
|
|
#include "RimVfpPlotCollection.h"
|
2024-05-13 08:54:40 +02:00
|
|
|
#include "RimVfpTableData.h"
|
2024-05-03 09:58:55 +02:00
|
|
|
|
|
|
|
|
#include "cafPdmUiTreeOrdering.h"
|
|
|
|
|
|
|
|
|
|
CAF_PDM_SOURCE_INIT( RimVfpDeck, "RimVfpDeck" );
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimVfpDeck::RimVfpDeck()
|
|
|
|
|
{
|
|
|
|
|
CAF_PDM_InitObject( "VFP Plot", ":/VfpPlot.svg" );
|
|
|
|
|
|
2024-05-13 08:54:40 +02:00
|
|
|
CAF_PDM_InitFieldNoDefault( &m_vfpTableData, "VfpTableData", "VFP Data Source" );
|
2024-05-03 09:58:55 +02:00
|
|
|
CAF_PDM_InitFieldNoDefault( &m_vfpPlotCollection, "VfpPlotCollection", "Plot Collection" );
|
|
|
|
|
m_vfpPlotCollection = new RimVfpPlotCollection();
|
|
|
|
|
|
|
|
|
|
setDeletable( true );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-05-13 08:54:40 +02:00
|
|
|
void RimVfpDeck::setDataSource( RimVfpTableData* tableData )
|
2024-05-03 09:58:55 +02:00
|
|
|
{
|
2024-05-13 08:54:40 +02:00
|
|
|
m_vfpTableData = tableData;
|
2024-05-03 09:58:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimVfpDeck::loadDataAndUpdate()
|
|
|
|
|
{
|
|
|
|
|
updateObjectName();
|
|
|
|
|
|
|
|
|
|
std::vector<RimVfpPlot*> currentPlots = m_vfpPlotCollection->plots();
|
|
|
|
|
|
2024-05-13 08:54:40 +02:00
|
|
|
if ( m_vfpTableData )
|
2024-05-03 09:58:55 +02:00
|
|
|
{
|
2024-05-13 08:54:40 +02:00
|
|
|
m_vfpTableData->ensureDataIsImported();
|
2024-05-03 09:58:55 +02:00
|
|
|
|
2024-05-13 08:54:40 +02:00
|
|
|
if ( m_vfpTableData->vfpTables() )
|
2024-05-03 09:58:55 +02:00
|
|
|
{
|
2024-05-13 08:54:40 +02:00
|
|
|
auto tables = m_vfpTableData->vfpTables();
|
|
|
|
|
|
|
|
|
|
auto allTableNumbers = tables->productionTableNumbers();
|
|
|
|
|
auto injTableNumbers = tables->injectionTableNumbers();
|
|
|
|
|
allTableNumbers.insert( allTableNumbers.end(), injTableNumbers.begin(), injTableNumbers.end() );
|
|
|
|
|
|
|
|
|
|
for ( const auto& number : allTableNumbers )
|
|
|
|
|
{
|
|
|
|
|
RimVfpPlot* plot = m_vfpPlotCollection->plotForTableNumber( number );
|
|
|
|
|
if ( !plot )
|
|
|
|
|
{
|
|
|
|
|
plot = new RimVfpPlot();
|
|
|
|
|
plot->setDataSource( m_vfpTableData );
|
|
|
|
|
plot->setTableNumber( number );
|
|
|
|
|
plot->initializeObject();
|
|
|
|
|
|
|
|
|
|
m_vfpPlotCollection->addPlot( plot );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
std::erase( currentPlots, plot );
|
|
|
|
|
}
|
|
|
|
|
plot->setDeletable( false );
|
|
|
|
|
plot->loadDataAndUpdate();
|
|
|
|
|
}
|
2024-05-03 09:58:55 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for ( auto plotToDelete : currentPlots )
|
|
|
|
|
{
|
|
|
|
|
m_vfpPlotCollection->removePlot( plotToDelete );
|
|
|
|
|
delete plotToDelete;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-13 08:54:40 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
std::vector<RimVfpPlot*> RimVfpDeck::plots() const
|
|
|
|
|
{
|
|
|
|
|
return m_vfpPlotCollection->plots();
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-03 09:58:55 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimVfpDeck::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName )
|
|
|
|
|
{
|
|
|
|
|
for ( auto p : m_vfpPlotCollection->plots() )
|
|
|
|
|
{
|
|
|
|
|
uiTreeOrdering.add( p );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uiTreeOrdering.skipRemainingChildren( true );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimVfpDeck::updateObjectName()
|
|
|
|
|
{
|
2024-05-13 08:54:40 +02:00
|
|
|
QString name = "VFP Deck";
|
2024-05-03 09:58:55 +02:00
|
|
|
|
2024-05-13 08:54:40 +02:00
|
|
|
if ( m_vfpTableData )
|
2024-05-03 09:58:55 +02:00
|
|
|
{
|
2024-05-13 08:54:40 +02:00
|
|
|
name = m_vfpTableData->name();
|
2024-05-03 09:58:55 +02:00
|
|
|
}
|
2024-05-13 08:54:40 +02:00
|
|
|
|
2024-05-03 09:58:55 +02:00
|
|
|
setName( name );
|
|
|
|
|
}
|
2024-05-13 08:54:40 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
QList<caf::PdmOptionItemInfo> RimVfpDeck::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
|
|
|
|
|
{
|
|
|
|
|
QList<caf::PdmOptionItemInfo> options;
|
|
|
|
|
if ( fieldNeedingOptions == &m_vfpTableData )
|
|
|
|
|
{
|
|
|
|
|
RimVfpDataCollection* vfpDataCollection = RimVfpDataCollection::instance();
|
|
|
|
|
for ( auto table : vfpDataCollection->vfpTableData() )
|
|
|
|
|
{
|
|
|
|
|
options.push_back( caf::PdmOptionItemInfo( table->name(), table ) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return options;
|
|
|
|
|
}
|