2020-11-13 03:56:25 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2020- 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 "RimVfpPlotCollection.h"
|
|
|
|
|
2024-05-29 05:55:45 -05:00
|
|
|
#include "RimCustomVfpPlot.h"
|
|
|
|
#include "RimVfpTable.h"
|
2024-05-03 02:58:55 -05:00
|
|
|
|
|
|
|
#include "cafCmdFeatureMenuBuilder.h"
|
2020-11-13 03:56:25 -06:00
|
|
|
|
|
|
|
CAF_PDM_SOURCE_INIT( RimVfpPlotCollection, "RimVfpPlotCollection" );
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimVfpPlotCollection::RimVfpPlotCollection()
|
|
|
|
{
|
2022-01-07 01:31:52 -06:00
|
|
|
CAF_PDM_InitObject( "VFP Plots", ":/VfpPlotCollection.svg" );
|
2020-11-13 03:56:25 -06:00
|
|
|
|
2024-05-29 05:55:45 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault( &m_customVfpPlots, "CustomVfpPlots", "Vertical Flow Performance Plots" );
|
2020-11-13 03:56:25 -06:00
|
|
|
}
|
|
|
|
|
2024-05-29 05:55:45 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimCustomVfpPlot* RimVfpPlotCollection::createAndAppendPlots( RimVfpTable* mainDataSource, std::vector<RimVfpTable*> tableData )
|
|
|
|
{
|
|
|
|
auto vfpPlot = new RimCustomVfpPlot();
|
|
|
|
vfpPlot->selectDataSource( mainDataSource, tableData );
|
|
|
|
vfpPlot->initializeObject();
|
2024-06-12 00:52:37 -05:00
|
|
|
vfpPlot->initializeSelection();
|
2024-06-18 02:28:16 -05:00
|
|
|
vfpPlot->createDefaultColors();
|
2024-05-29 05:55:45 -05:00
|
|
|
|
|
|
|
m_customVfpPlots.push_back( vfpPlot );
|
|
|
|
|
|
|
|
vfpPlot->loadDataAndUpdate();
|
|
|
|
|
|
|
|
return vfpPlot;
|
|
|
|
}
|
|
|
|
|
2020-11-13 03:56:25 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-11-01 10:02:57 -05:00
|
|
|
void RimVfpPlotCollection::addPlot( RimCustomVfpPlot* newPlot )
|
2020-12-21 12:43:36 -06:00
|
|
|
{
|
2024-11-01 10:02:57 -05:00
|
|
|
m_customVfpPlots.push_back( newPlot );
|
2020-12-21 12:43:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-11-01 10:02:57 -05:00
|
|
|
void RimVfpPlotCollection::insertPlot( RimCustomVfpPlot* vfpPlot, size_t index )
|
2020-11-13 03:56:25 -06:00
|
|
|
{
|
2024-11-01 10:02:57 -05:00
|
|
|
m_customVfpPlots.insert( index, vfpPlot );
|
2020-11-13 03:56:25 -06:00
|
|
|
}
|
|
|
|
|
2024-05-03 02:58:55 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-11-01 10:02:57 -05:00
|
|
|
std::vector<RimCustomVfpPlot*> RimVfpPlotCollection::plots() const
|
2024-05-03 02:58:55 -05:00
|
|
|
{
|
2024-11-01 10:02:57 -05:00
|
|
|
return m_customVfpPlots.childrenByType();
|
2024-05-03 02:58:55 -05:00
|
|
|
}
|
|
|
|
|
2020-12-21 12:43:36 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
size_t RimVfpPlotCollection::plotCount() const
|
|
|
|
{
|
2024-11-01 10:02:57 -05:00
|
|
|
return m_customVfpPlots.size() + m_customVfpPlots.size();
|
2020-12-21 12:43:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-11-01 10:02:57 -05:00
|
|
|
void RimVfpPlotCollection::removePlot( RimCustomVfpPlot* vfpPlot )
|
2020-12-21 12:43:36 -06:00
|
|
|
{
|
2024-11-01 10:02:57 -05:00
|
|
|
m_customVfpPlots.removeChild( vfpPlot );
|
2020-12-21 12:43:36 -06:00
|
|
|
updateAllRequiredEditors();
|
|
|
|
}
|
2024-05-03 02:58:55 -05:00
|
|
|
|
2024-05-13 01:54:40 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimVfpPlotCollection::deleteAllPlots()
|
|
|
|
{
|
2024-05-29 05:55:45 -05:00
|
|
|
m_customVfpPlots.deleteChildren();
|
2024-05-13 01:54:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimVfpPlotCollection::addImportItems( caf::CmdFeatureMenuBuilder& menuBuilder )
|
|
|
|
{
|
|
|
|
// A variant with a true value is used to indicate that the VFP data is imported from a file
|
|
|
|
// This is used to distinguish between VFP data imported from a file and VFP data imported from a simulator
|
|
|
|
QVariant variant( QVariant::fromValue( true ) );
|
|
|
|
menuBuilder.addCmdFeatureWithUserData( "RicImportVfpDataFeature", "Import VFP Files", variant );
|
|
|
|
menuBuilder.addCmdFeature( "RicImportVfpDataFeature", "Import VFP from Simulator Files" );
|
2024-05-03 02:58:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimVfpPlotCollection::onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, std::vector<caf::PdmObjectHandle*>& updatedObjects )
|
|
|
|
{
|
|
|
|
for ( auto plot : plots() )
|
|
|
|
{
|
|
|
|
plot->updateMdiWindowVisibility();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimVfpPlotCollection::loadDataAndUpdateAllPlots()
|
|
|
|
{
|
|
|
|
for ( auto plot : plots() )
|
|
|
|
{
|
|
|
|
plot->loadDataAndUpdate();
|
|
|
|
}
|
|
|
|
|
2024-05-29 05:55:45 -05:00
|
|
|
for ( auto customPlot : m_customVfpPlots.childrenByType() )
|
2024-05-03 02:58:55 -05:00
|
|
|
{
|
2024-05-29 05:55:45 -05:00
|
|
|
customPlot->loadDataAndUpdate();
|
2024-05-03 02:58:55 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimVfpPlotCollection::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const
|
|
|
|
{
|
2024-05-13 01:54:40 -05:00
|
|
|
addImportItems( menuBuilder );
|
2024-05-03 02:58:55 -05:00
|
|
|
}
|