2022-03-04 10:52:17 +01: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 "RimSummaryMultiPlotCollection.h"
|
|
|
|
|
|
|
|
|
|
#include "RimProject.h"
|
|
|
|
|
#include "RimSummaryMultiPlot.h"
|
2022-03-27 20:25:03 +02:00
|
|
|
#include "RimSummaryPlot.h"
|
2025-10-16 14:09:15 +02:00
|
|
|
#include "RimSummaryPlotReadOut.h"
|
2025-07-27 09:04:50 +02:00
|
|
|
#include "RimTools.h"
|
2022-03-04 10:52:17 +01:00
|
|
|
|
2022-03-16 14:14:14 +01:00
|
|
|
#include "RiuPlotMainWindowTools.h"
|
|
|
|
|
|
2022-03-04 10:52:17 +01:00
|
|
|
#include "cafPdmFieldReorderCapability.h"
|
2025-10-16 14:09:15 +02:00
|
|
|
#include "cafPdmUiCheckBoxEditor.h"
|
2022-03-27 20:25:03 +02:00
|
|
|
#include "cafPdmUiTreeOrdering.h"
|
2022-03-04 10:52:17 +01:00
|
|
|
|
|
|
|
|
CAF_PDM_SOURCE_INIT( RimSummaryMultiPlotCollection, "RimSummaryMultiPlotCollection" );
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimSummaryMultiPlotCollection::RimSummaryMultiPlotCollection()
|
|
|
|
|
{
|
2022-03-21 12:23:50 +01:00
|
|
|
CAF_PDM_InitObject( "Summary Plots", ":/MultiPlot16x16.png" );
|
2022-03-04 10:52:17 +01:00
|
|
|
|
2022-03-21 12:23:50 +01:00
|
|
|
CAF_PDM_InitFieldNoDefault( &m_summaryMultiPlots, "MultiSummaryPlots", "Summary Plots" );
|
2022-03-04 10:52:17 +01:00
|
|
|
caf::PdmFieldReorderCapability::addToField( &m_summaryMultiPlots );
|
2025-10-16 14:09:15 +02:00
|
|
|
|
|
|
|
|
CAF_PDM_InitField( &m_useCommonReadoutSettings, "UseCommonReadoutSettings", false, "Use Common Readout Settings" );
|
|
|
|
|
caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_useCommonReadoutSettings );
|
|
|
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault( &m_readoutSettings, "ReadOutSettings", "Read Out Settings" );
|
|
|
|
|
m_readoutSettings = new RimSummaryPlotReadOut;
|
|
|
|
|
m_readoutSettings.uiCapability()->setUiTreeChildrenHidden( true );
|
2022-03-04 10:52:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimSummaryMultiPlotCollection::~RimSummaryMultiPlotCollection()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-16 14:14:14 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimSummaryMultiPlotCollection::initAfterRead()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-04 10:52:17 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimSummaryMultiPlotCollection::deleteAllPlots()
|
|
|
|
|
{
|
2022-05-31 13:08:07 +02:00
|
|
|
m_summaryMultiPlots.deleteChildren();
|
2022-03-04 10:52:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
std::vector<RimSummaryMultiPlot*> RimSummaryMultiPlotCollection::multiPlots() const
|
|
|
|
|
{
|
2023-05-12 21:41:34 +02:00
|
|
|
return m_summaryMultiPlots.childrenByType();
|
2022-03-04 10:52:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2022-03-21 11:31:25 +01:00
|
|
|
void RimSummaryMultiPlotCollection::addSummaryMultiPlot( RimSummaryMultiPlot* plot )
|
2022-03-04 10:52:17 +01:00
|
|
|
{
|
|
|
|
|
m_summaryMultiPlots().push_back( plot );
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-02 06:50:14 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimSummaryMultiPlotCollection::removePlotNoUpdate( RimSummaryMultiPlot* plot )
|
|
|
|
|
{
|
|
|
|
|
if ( plot == nullptr ) return;
|
|
|
|
|
m_summaryMultiPlots().removeChild( plot );
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-04 10:52:17 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimSummaryMultiPlotCollection::loadDataAndUpdateAllPlots()
|
|
|
|
|
{
|
2023-05-12 21:41:34 +02:00
|
|
|
for ( const auto& p : m_summaryMultiPlots.childrenByType() )
|
2022-03-04 10:52:17 +01:00
|
|
|
p->loadDataAndUpdate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
size_t RimSummaryMultiPlotCollection::plotCount() const
|
|
|
|
|
{
|
|
|
|
|
return m_summaryMultiPlots.size();
|
|
|
|
|
}
|
2022-03-16 14:14:14 +01:00
|
|
|
|
2025-10-16 14:09:15 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimSummaryMultiPlotCollection::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
|
|
|
|
|
{
|
|
|
|
|
if ( changedField == &m_useCommonReadoutSettings )
|
|
|
|
|
{
|
|
|
|
|
updateReadOutSettingsInSubPlots();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimSummaryMultiPlotCollection::childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField )
|
|
|
|
|
{
|
|
|
|
|
if ( changedChildField == &m_readoutSettings )
|
|
|
|
|
{
|
|
|
|
|
updateReadOutSettingsInSubPlots();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimSummaryMultiPlotCollection::updateReadOutSettingsInSubPlots()
|
|
|
|
|
{
|
|
|
|
|
for ( auto plot : m_summaryMultiPlots )
|
|
|
|
|
{
|
|
|
|
|
plot->updateReadOutSettings();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-27 20:25:03 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-02-26 10:48:40 +01:00
|
|
|
void RimSummaryMultiPlotCollection::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/ )
|
2022-03-27 20:25:03 +02:00
|
|
|
{
|
|
|
|
|
for ( auto& plot : m_summaryMultiPlots() )
|
|
|
|
|
{
|
2022-04-01 19:23:27 +02:00
|
|
|
uiTreeOrdering.add( plot );
|
2022-03-27 20:25:03 +02:00
|
|
|
}
|
|
|
|
|
uiTreeOrdering.skipRemainingChildren( true );
|
|
|
|
|
}
|
2022-04-06 17:39:07 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2025-07-27 09:04:50 +02:00
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimSummaryMultiPlotCollection::onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray,
|
|
|
|
|
std::vector<caf::PdmObjectHandle*>& updatedObjects )
|
|
|
|
|
{
|
|
|
|
|
if ( childArray == &m_summaryMultiPlots )
|
|
|
|
|
{
|
|
|
|
|
RimTools::updateViewWindowContent( updatedObjects );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-16 14:09:15 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimSummaryMultiPlotCollection::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
|
|
|
|
{
|
|
|
|
|
uiOrdering.add( &m_useCommonReadoutSettings );
|
|
|
|
|
|
|
|
|
|
auto readOutGroup = uiOrdering.addNewGroup( "Mouse Cursor Readout" );
|
|
|
|
|
m_readoutSettings->uiOrdering( uiConfigName, *readOutGroup );
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-27 09:04:50 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2022-04-06 17:39:07 +02:00
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimSummaryMultiPlotCollection::summaryPlotItemInfos( QList<caf::PdmOptionItemInfo>* optionInfos ) const
|
|
|
|
|
{
|
|
|
|
|
for ( RimSummaryMultiPlot* multiPlot : multiPlots() )
|
|
|
|
|
{
|
2025-02-14 09:35:28 +01:00
|
|
|
auto mainPlotName = multiPlot->description();
|
|
|
|
|
|
2022-04-06 17:39:07 +02:00
|
|
|
for ( RimSummaryPlot* plot : multiPlot->summaryPlots() )
|
|
|
|
|
{
|
2025-02-14 09:35:28 +01:00
|
|
|
QString displayName = mainPlotName + " : ";
|
|
|
|
|
displayName += plot->userDescriptionField()->uiCapability()->uiValue().toString();
|
|
|
|
|
optionInfos->push_back( caf::PdmOptionItemInfo( displayName, plot, false, plot->uiIconProvider() ) );
|
2022-04-06 17:39:07 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-23 14:25:53 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2026-03-18 11:00:53 +01:00
|
|
|
RimSummaryMultiPlot* RimSummaryMultiPlotCollection::duplicatePlot( RimSummaryMultiPlot* plotToDuplicate )
|
2022-05-23 14:25:53 +02:00
|
|
|
{
|
2026-03-18 11:00:53 +01:00
|
|
|
if ( !plotToDuplicate ) return nullptr;
|
2022-05-23 14:25:53 +02:00
|
|
|
|
2024-06-14 17:18:28 +02:00
|
|
|
auto plotCopy = plotToDuplicate->copyObject<RimSummaryMultiPlot>();
|
2026-06-02 17:29:04 +02:00
|
|
|
plotCopy->resetDockWindowId();
|
2022-05-23 14:25:53 +02:00
|
|
|
addSummaryMultiPlot( plotCopy );
|
|
|
|
|
|
2026-07-29 11:53:44 +02:00
|
|
|
plotCopy->initAfterInsert();
|
2022-05-23 14:25:53 +02:00
|
|
|
plotCopy->updateAllRequiredEditors();
|
|
|
|
|
plotCopy->loadDataAndUpdate();
|
|
|
|
|
|
|
|
|
|
updateConnectedEditors();
|
|
|
|
|
|
2022-08-18 03:37:51 -07:00
|
|
|
RiuPlotMainWindowTools::selectAsCurrentItem( plotCopy );
|
2026-03-18 11:00:53 +01:00
|
|
|
|
|
|
|
|
return plotCopy;
|
2022-05-23 14:25:53 +02:00
|
|
|
}
|
|
|
|
|
|
2022-04-06 17:39:07 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimSummaryMultiPlotCollection::updateSummaryNameHasChanged()
|
|
|
|
|
{
|
|
|
|
|
for ( RimSummaryMultiPlot* multiPlot : multiPlots() )
|
|
|
|
|
{
|
|
|
|
|
for ( RimSummaryPlot* plot : multiPlot->summaryPlots() )
|
|
|
|
|
{
|
|
|
|
|
plot->updateCaseNameHasChanged();
|
|
|
|
|
}
|
2022-12-09 08:46:36 +01:00
|
|
|
|
|
|
|
|
multiPlot->updatePlotTitles();
|
2022-04-06 17:39:07 +02:00
|
|
|
}
|
2025-05-15 18:16:27 +02:00
|
|
|
|
|
|
|
|
updateConnectedEditors();
|
2022-04-06 17:39:07 +02:00
|
|
|
}
|
2025-10-16 14:09:15 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
std::optional<RimSummaryPlotReadOut*> RimSummaryMultiPlotCollection::commonReadOutSettings() const
|
|
|
|
|
{
|
|
|
|
|
if ( m_useCommonReadoutSettings() )
|
|
|
|
|
{
|
|
|
|
|
return m_readoutSettings();
|
|
|
|
|
}
|
|
|
|
|
return std::nullopt;
|
|
|
|
|
}
|