2021-12-23 02:30:36 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2021 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.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2022-03-10 06:13:44 -06:00
|
|
|
#include "RimSummaryMultiPlot.h"
|
2021-12-23 02:30:36 -06:00
|
|
|
|
2022-01-10 07:51:31 -06:00
|
|
|
#include "RiaSummaryAddressAnalyzer.h"
|
2021-12-23 02:30:36 -06:00
|
|
|
#include "RiaSummaryStringTools.h"
|
|
|
|
|
2022-01-06 08:18:09 -06:00
|
|
|
#include "RimEnsembleCurveSet.h"
|
2021-12-23 02:30:36 -06:00
|
|
|
#include "RimMainPlotCollection.h"
|
|
|
|
#include "RimMultiPlotCollection.h"
|
2022-01-06 08:18:09 -06:00
|
|
|
#include "RimMultipleSummaryPlotNameHelper.h"
|
2021-12-23 02:30:36 -06:00
|
|
|
#include "RimProject.h"
|
|
|
|
#include "RimSummaryCase.h"
|
|
|
|
#include "RimSummaryCaseCollection.h"
|
2022-01-06 08:18:09 -06:00
|
|
|
#include "RimSummaryCurve.h"
|
2022-03-04 03:52:17 -06:00
|
|
|
#include "RimSummaryPlotControls.h"
|
2022-01-10 07:51:31 -06:00
|
|
|
|
2022-03-10 06:13:44 -06:00
|
|
|
#include "RimMultiPlot.h"
|
2022-03-16 08:14:14 -05:00
|
|
|
#include "RimSummaryAddress.h"
|
2021-12-23 02:30:36 -06:00
|
|
|
#include "RimSummaryPlot.h"
|
2022-01-06 08:18:09 -06:00
|
|
|
#include "RimSummaryPlotNameHelper.h"
|
|
|
|
#include "RimSummaryPlotSourceStepping.h"
|
2021-12-23 02:30:36 -06:00
|
|
|
|
|
|
|
#include "RiuSummaryVectorSelectionUi.h"
|
|
|
|
|
|
|
|
#include "cafPdmUiComboBoxEditor.h"
|
2022-03-08 09:16:07 -06:00
|
|
|
#include "cafPdmUiPushButtonEditor.h"
|
2021-12-23 02:30:36 -06:00
|
|
|
#include "cafPdmUiTreeOrdering.h"
|
|
|
|
#include "cafPdmUiTreeSelectionEditor.h"
|
|
|
|
|
2022-03-10 06:13:44 -06:00
|
|
|
#include <QKeyEvent>
|
|
|
|
|
2021-12-23 02:30:36 -06:00
|
|
|
CAF_PDM_SOURCE_INIT( RimSummaryMultiPlot, "MultiSummaryPlot" );
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimSummaryMultiPlot::RimSummaryMultiPlot()
|
2022-03-16 08:14:14 -05:00
|
|
|
: duplicatePlot( this )
|
2021-12-23 02:30:36 -06:00
|
|
|
{
|
2022-04-06 01:44:44 -05:00
|
|
|
CAF_PDM_InitObject( "Multi Summary Plot", ":/SummaryPlotLight16x16.png" );
|
2021-12-23 02:30:36 -06:00
|
|
|
this->setDeletable( true );
|
|
|
|
|
2022-03-04 03:52:17 -06:00
|
|
|
CAF_PDM_InitField( &m_autoPlotTitles, "AutoPlotTitles", true, "Auto Plot Titles" );
|
|
|
|
CAF_PDM_InitField( &m_autoPlotTitlesOnSubPlots, "AutoPlotTitlesSubPlots", true, "Auto Plot Titles Sub Plots" );
|
2022-01-06 08:18:09 -06:00
|
|
|
|
2022-03-08 09:16:07 -06:00
|
|
|
CAF_PDM_InitField( &m_syncAxisRanges, "SyncAxisRanges", false, "", "", "Sync Axis Ranges in All Plots" );
|
|
|
|
m_syncAxisRanges.xmlCapability()->disableIO();
|
|
|
|
m_syncAxisRanges.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
|
|
|
|
m_syncAxisRanges.uiCapability()->setUiIconFromResourceString( ":/AxesSync16x16.png" );
|
|
|
|
|
2022-03-16 08:14:14 -05:00
|
|
|
CAF_PDM_InitField( &m_createPlotDuplicate, "DuplicatePlot", false, "", "", "Duplicate Plot" );
|
|
|
|
m_createPlotDuplicate.xmlCapability()->disableIO();
|
|
|
|
m_createPlotDuplicate.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
|
|
|
|
m_createPlotDuplicate.uiCapability()->setUiIconFromResourceString( ":/Copy.svg" );
|
|
|
|
|
2022-03-10 06:13:44 -06:00
|
|
|
CAF_PDM_InitField( &m_disableWheelZoom, "DisableWheelZoom", true, "", "", "Disable Mouse Wheel Zooming in Multi Summary Plot" );
|
|
|
|
m_disableWheelZoom.xmlCapability()->disableIO();
|
|
|
|
m_disableWheelZoom.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
|
|
|
|
m_disableWheelZoom.uiCapability()->setUiIconFromResourceString( ":/DisableZoom.png" );
|
|
|
|
|
2022-04-04 08:10:39 -05:00
|
|
|
CAF_PDM_InitField( &m_syncSubPlotAxes, "SyncSubPlotAxes", false, "Sync Subplot Axes" );
|
|
|
|
|
2022-01-06 08:18:09 -06:00
|
|
|
CAF_PDM_InitFieldNoDefault( &m_sourceStepping, "SourceStepping", "" );
|
|
|
|
m_sourceStepping = new RimSummaryPlotSourceStepping;
|
|
|
|
m_sourceStepping->setSourceSteppingType( RimSummaryDataSourceStepping::Axis::Y_AXIS );
|
|
|
|
m_sourceStepping->setSourceSteppingObject( this );
|
|
|
|
m_sourceStepping.uiCapability()->setUiTreeHidden( true );
|
|
|
|
m_sourceStepping.uiCapability()->setUiTreeChildrenHidden( true );
|
|
|
|
m_sourceStepping.xmlCapability()->disableIO();
|
|
|
|
|
|
|
|
m_nameHelper = std::make_unique<RimSummaryPlotNameHelper>();
|
2021-12-23 02:30:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimSummaryMultiPlot::~RimSummaryMultiPlot()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2022-03-04 03:52:17 -06:00
|
|
|
void RimSummaryMultiPlot::addPlot( RimPlot* plot )
|
2021-12-23 02:30:36 -06:00
|
|
|
{
|
2022-03-04 03:52:17 -06:00
|
|
|
RimSummaryPlot* sumPlot = dynamic_cast<RimSummaryPlot*>( plot );
|
|
|
|
CVF_ASSERT( sumPlot != nullptr );
|
2022-03-15 09:57:15 -05:00
|
|
|
if ( sumPlot )
|
|
|
|
{
|
|
|
|
RimMultiPlot::addPlot( plot );
|
|
|
|
}
|
2021-12-23 02:30:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2022-03-04 03:52:17 -06:00
|
|
|
void RimSummaryMultiPlot::insertPlot( RimPlot* plot, size_t index )
|
2021-12-23 02:30:36 -06:00
|
|
|
{
|
2022-03-04 03:52:17 -06:00
|
|
|
RimSummaryPlot* sumPlot = dynamic_cast<RimSummaryPlot*>( plot );
|
|
|
|
CVF_ASSERT( sumPlot != nullptr );
|
2022-03-15 09:57:15 -05:00
|
|
|
if ( sumPlot )
|
|
|
|
{
|
2022-04-04 08:10:39 -05:00
|
|
|
sumPlot->axisChanged.connect( this, &RimSummaryMultiPlot::onSubPlotAxisChanged );
|
2022-03-23 07:35:47 -05:00
|
|
|
sumPlot->curvesChanged.connect( this, &RimSummaryMultiPlot::onSubPlotChanged );
|
2022-03-15 09:57:15 -05:00
|
|
|
RimMultiPlot::insertPlot( plot, index );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimSummaryMultiPlot::addPlot( const std::vector<caf::PdmObjectHandle*>& objects )
|
|
|
|
{
|
2022-03-16 08:14:14 -05:00
|
|
|
if ( objects.empty() ) return;
|
|
|
|
|
|
|
|
RimSummaryAddress* addr = dynamic_cast<RimSummaryAddress*>( objects[0] );
|
|
|
|
if ( addr )
|
|
|
|
{
|
|
|
|
RimSummaryPlot* plot = new RimSummaryPlot();
|
|
|
|
plot->enableAutoPlotTitle( true );
|
2022-03-15 09:57:15 -05:00
|
|
|
|
2022-03-16 08:14:14 -05:00
|
|
|
plot->handleDroppedObjects( objects );
|
2022-03-23 07:35:47 -05:00
|
|
|
|
|
|
|
addPlot( plot );
|
2022-03-16 08:14:14 -05:00
|
|
|
}
|
2022-03-15 09:57:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimSummaryMultiPlot::removePlot( RimPlot* plot )
|
|
|
|
{
|
|
|
|
RimSummaryPlot* sumPlot = dynamic_cast<RimSummaryPlot*>( plot );
|
|
|
|
CVF_ASSERT( sumPlot != nullptr );
|
|
|
|
if ( sumPlot )
|
|
|
|
{
|
|
|
|
RimMultiPlot::removePlot( plot );
|
|
|
|
}
|
2021-12-23 02:30:36 -06:00
|
|
|
}
|
|
|
|
|
2022-04-01 12:23:27 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimSummaryMultiPlot::removePlotNoUpdate( RimPlot* plot )
|
|
|
|
{
|
|
|
|
RimSummaryPlot* sumPlot = dynamic_cast<RimSummaryPlot*>( plot );
|
|
|
|
CVF_ASSERT( sumPlot != nullptr );
|
|
|
|
if ( sumPlot )
|
|
|
|
{
|
|
|
|
RimMultiPlot::removePlotNoUpdate( plot );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimSummaryMultiPlot::updateAfterPlotRemove()
|
|
|
|
{
|
|
|
|
onPlotAdditionOrRemoval();
|
|
|
|
}
|
|
|
|
|
2022-01-06 08:18:09 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<RimSummaryDataSourceStepping::Axis> RimSummaryMultiPlot::availableAxes() const
|
|
|
|
{
|
|
|
|
return { RimSummaryDataSourceStepping::Axis::X_AXIS };
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<RimSummaryCurve*> RimSummaryMultiPlot::curvesForStepping( RimSummaryDataSourceStepping::Axis axis ) const
|
|
|
|
{
|
|
|
|
std::vector<RimSummaryCurve*> curves;
|
|
|
|
|
|
|
|
for ( auto summaryPlot : summaryPlots() )
|
|
|
|
{
|
|
|
|
for ( auto curve : summaryPlot->curvesForStepping( axis ) )
|
|
|
|
{
|
|
|
|
curves.push_back( curve );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return curves;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<RimEnsembleCurveSet*> RimSummaryMultiPlot::curveSets() const
|
|
|
|
{
|
|
|
|
std::vector<RimEnsembleCurveSet*> curveSets;
|
|
|
|
|
|
|
|
for ( auto summaryPlot : summaryPlots() )
|
|
|
|
{
|
|
|
|
for ( auto curveSet : summaryPlot->curveSets() )
|
|
|
|
{
|
|
|
|
curveSets.push_back( curveSet );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return curveSets;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<RimSummaryCurve*> RimSummaryMultiPlot::allCurves( RimSummaryDataSourceStepping::Axis axis ) const
|
|
|
|
{
|
|
|
|
std::vector<RimSummaryCurve*> curves;
|
|
|
|
|
|
|
|
for ( auto summaryPlot : summaryPlots() )
|
|
|
|
{
|
|
|
|
for ( auto curve : summaryPlot->allCurves( axis ) )
|
|
|
|
{
|
|
|
|
curves.push_back( curve );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return curves;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimSummaryMultiPlot::populateNameHelper( RimSummaryPlotNameHelper* nameHelper )
|
|
|
|
{
|
|
|
|
nameHelper->clear();
|
|
|
|
|
|
|
|
std::vector<RifEclipseSummaryAddress> addresses;
|
|
|
|
std::vector<RimSummaryCase*> sumCases;
|
|
|
|
std::vector<RimSummaryCaseCollection*> ensembleCases;
|
|
|
|
|
|
|
|
for ( RimSummaryCurve* curve : allCurves( RimSummaryDataSourceStepping::Axis::Y_AXIS ) )
|
|
|
|
{
|
|
|
|
addresses.push_back( curve->summaryAddressY() );
|
|
|
|
sumCases.push_back( curve->summaryCaseY() );
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( auto curveSet : curveSets() )
|
|
|
|
{
|
|
|
|
addresses.push_back( curveSet->summaryAddress() );
|
|
|
|
ensembleCases.push_back( curveSet->summaryCaseCollection() );
|
|
|
|
}
|
|
|
|
|
|
|
|
nameHelper->appendAddresses( addresses );
|
|
|
|
nameHelper->setSummaryCases( sumCases );
|
|
|
|
nameHelper->setEnsembleCases( ensembleCases );
|
|
|
|
}
|
|
|
|
|
2021-12-23 02:30:36 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimSummaryMultiPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
|
|
|
{
|
2022-04-06 03:47:10 -05:00
|
|
|
auto titlesGroup = uiOrdering.addNewGroup( "Main Plot Settings" );
|
2022-03-04 03:52:17 -06:00
|
|
|
titlesGroup->add( &m_autoPlotTitles );
|
|
|
|
titlesGroup->add( &m_showPlotWindowTitle );
|
|
|
|
titlesGroup->add( &m_plotWindowTitle );
|
|
|
|
titlesGroup->add( &m_titleFontSize );
|
|
|
|
|
2022-04-06 03:47:10 -05:00
|
|
|
auto subPlotSettingsGroup = uiOrdering.addNewGroup( "Sub Plot Settings" );
|
|
|
|
subPlotSettingsGroup->add( &m_autoPlotTitlesOnSubPlots );
|
|
|
|
subPlotSettingsGroup->add( &m_showIndividualPlotTitles );
|
|
|
|
subPlotSettingsGroup->add( &m_subTitleFontSize );
|
|
|
|
|
|
|
|
auto legendsGroup = uiOrdering.addNewGroup( "Legends" );
|
2022-03-04 03:52:17 -06:00
|
|
|
legendsGroup->add( &m_showPlotLegends );
|
|
|
|
legendsGroup->add( &m_plotLegendsHorizontal );
|
|
|
|
legendsGroup->add( &m_legendFontSize );
|
|
|
|
|
2022-04-06 03:47:10 -05:00
|
|
|
auto layoutGroup = uiOrdering.addNewGroup( "Layout" );
|
2022-03-04 03:52:17 -06:00
|
|
|
layoutGroup->add( &m_columnCount );
|
|
|
|
layoutGroup->add( &m_rowsPerPage );
|
|
|
|
layoutGroup->add( &m_majorTickmarkCount );
|
|
|
|
|
2022-04-06 03:47:10 -05:00
|
|
|
auto axesGroup = uiOrdering.addNewGroup( "Axes" );
|
2022-04-04 08:10:39 -05:00
|
|
|
axesGroup->add( &m_syncSubPlotAxes );
|
|
|
|
|
2022-04-06 03:47:10 -05:00
|
|
|
auto dataSourceGroup = uiOrdering.addNewGroup( "Data Source" );
|
|
|
|
m_sourceStepping()->uiOrdering( uiConfigName, *dataSourceGroup );
|
2022-04-05 06:57:47 -05:00
|
|
|
|
2022-03-04 03:52:17 -06:00
|
|
|
uiOrdering.skipRemainingFields( true );
|
2021-12-23 02:30:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimSummaryMultiPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
|
|
|
const QVariant& oldValue,
|
|
|
|
const QVariant& newValue )
|
|
|
|
{
|
2022-03-04 03:52:17 -06:00
|
|
|
if ( changedField == &m_autoPlotTitles || changedField == &m_autoPlotTitlesOnSubPlots )
|
2022-01-06 08:18:09 -06:00
|
|
|
{
|
|
|
|
onLoadDataAndUpdate();
|
|
|
|
updateLayout();
|
|
|
|
}
|
2022-03-08 09:16:07 -06:00
|
|
|
else if ( changedField == &m_syncAxisRanges )
|
|
|
|
{
|
|
|
|
m_syncAxisRanges = false;
|
2022-03-16 08:14:14 -05:00
|
|
|
syncAxisRanges();
|
|
|
|
}
|
|
|
|
else if ( changedField == &m_createPlotDuplicate )
|
|
|
|
{
|
|
|
|
m_createPlotDuplicate = false;
|
|
|
|
duplicate();
|
2022-03-08 09:16:07 -06:00
|
|
|
}
|
2022-04-06 03:47:10 -05:00
|
|
|
else if ( changedField == &m_syncSubPlotAxes && m_syncSubPlotAxes() )
|
|
|
|
{
|
|
|
|
syncAxisRanges();
|
|
|
|
}
|
2022-03-04 03:52:17 -06:00
|
|
|
else
|
2021-12-23 02:30:36 -06:00
|
|
|
{
|
2022-03-04 03:52:17 -06:00
|
|
|
RimMultiPlot::fieldChangedByUi( changedField, oldValue, newValue );
|
2021-12-23 02:30:36 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-08 09:16:07 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimSummaryMultiPlot::defineEditorAttribute( const caf::PdmFieldHandle* field,
|
|
|
|
QString uiConfigName,
|
|
|
|
caf::PdmUiEditorAttribute* attribute )
|
|
|
|
{
|
|
|
|
if ( &m_syncAxisRanges == field )
|
|
|
|
{
|
|
|
|
caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute );
|
|
|
|
if ( attrib )
|
|
|
|
{
|
|
|
|
attrib->m_buttonText = "Sync Axes";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-23 02:30:36 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2022-03-04 03:52:17 -06:00
|
|
|
void RimSummaryMultiPlot::updatePlotWindowTitle()
|
2021-12-23 02:30:36 -06:00
|
|
|
{
|
2022-03-04 03:52:17 -06:00
|
|
|
if ( m_autoPlotTitles )
|
2021-12-23 02:30:36 -06:00
|
|
|
{
|
2022-03-04 03:52:17 -06:00
|
|
|
populateNameHelper( m_nameHelper.get() );
|
2021-12-23 02:30:36 -06:00
|
|
|
|
2022-03-04 03:52:17 -06:00
|
|
|
auto title = m_nameHelper->plotTitle();
|
2022-03-25 05:39:12 -05:00
|
|
|
if ( title.isEmpty() ) title = "Empty Plot";
|
2022-03-04 03:52:17 -06:00
|
|
|
setMultiPlotTitle( title );
|
2022-01-06 08:18:09 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( m_autoPlotTitlesOnSubPlots )
|
|
|
|
{
|
|
|
|
for ( auto plot : summaryPlots() )
|
|
|
|
{
|
|
|
|
auto subPlotNameHelper = plot->plotTitleHelper();
|
|
|
|
|
|
|
|
// Disable auto plot, as this is required to be able to include the information in the multi plot title
|
|
|
|
plot->enableAutoPlotTitle( false );
|
|
|
|
|
2022-01-10 07:51:31 -06:00
|
|
|
auto plotName = subPlotNameHelper->aggregatedPlotTitle( *m_nameHelper );
|
2022-01-06 08:18:09 -06:00
|
|
|
plot->setDescription( plotName );
|
|
|
|
plot->updatePlotTitle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
const RimSummaryNameHelper* RimSummaryMultiPlot::nameHelper() const
|
|
|
|
{
|
|
|
|
return m_nameHelper.get();
|
|
|
|
}
|
|
|
|
|
2022-01-10 07:51:31 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimSummaryMultiPlot::setAutoTitlePlot( bool enable )
|
|
|
|
{
|
|
|
|
m_autoPlotTitles = enable;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimSummaryMultiPlot::setAutoTitleGraphs( bool enable )
|
|
|
|
{
|
|
|
|
m_autoPlotTitlesOnSubPlots = enable;
|
|
|
|
}
|
|
|
|
|
2022-01-06 08:18:09 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<RimSummaryPlot*> RimSummaryMultiPlot::summaryPlots() const
|
|
|
|
{
|
|
|
|
std::vector<RimSummaryPlot*> typedPlots;
|
|
|
|
|
2022-03-04 03:52:17 -06:00
|
|
|
for ( auto plot : plots() )
|
2022-01-06 08:18:09 -06:00
|
|
|
{
|
|
|
|
auto summaryPlot = dynamic_cast<RimSummaryPlot*>( plot );
|
|
|
|
if ( summaryPlot ) typedPlots.push_back( summaryPlot );
|
2021-12-23 02:30:36 -06:00
|
|
|
}
|
2022-01-06 08:18:09 -06:00
|
|
|
|
|
|
|
return typedPlots;
|
2021-12-23 02:30:36 -06:00
|
|
|
}
|
2022-01-10 07:51:31 -06:00
|
|
|
|
2022-04-01 12:23:27 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<RimSummaryPlot*> RimSummaryMultiPlot::visibleSummaryPlots() const
|
|
|
|
{
|
|
|
|
std::vector<RimSummaryPlot*> visiblePlots;
|
|
|
|
|
|
|
|
for ( auto plot : summaryPlots() )
|
|
|
|
{
|
|
|
|
if ( plot->showWindow() ) visiblePlots.push_back( plot );
|
|
|
|
}
|
|
|
|
|
|
|
|
return visiblePlots;
|
|
|
|
}
|
|
|
|
|
2022-03-04 03:52:17 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<caf::PdmFieldHandle*> RimSummaryMultiPlot::fieldsToShowInToolbar()
|
|
|
|
{
|
|
|
|
std::vector<caf::PdmFieldHandle*> toolBarFields;
|
|
|
|
|
2022-03-10 06:13:44 -06:00
|
|
|
toolBarFields.push_back( &m_disableWheelZoom );
|
2022-03-08 09:16:07 -06:00
|
|
|
toolBarFields.push_back( &m_syncAxisRanges );
|
2022-03-16 08:14:14 -05:00
|
|
|
toolBarFields.push_back( &m_createPlotDuplicate );
|
2022-03-08 09:16:07 -06:00
|
|
|
|
2022-03-04 03:52:17 -06:00
|
|
|
auto& sourceObject = m_sourceStepping();
|
|
|
|
if ( sourceObject )
|
|
|
|
{
|
|
|
|
auto fields = sourceObject->fieldsToShowInToolbar();
|
|
|
|
toolBarFields.insert( std::end( toolBarFields ), std::begin( fields ), std::end( fields ) );
|
|
|
|
}
|
|
|
|
|
2022-04-07 09:24:27 -05:00
|
|
|
auto multiFields = RimMultiPlot::fieldsToShowInToolbar();
|
|
|
|
toolBarFields.insert( std::end( toolBarFields ), std::begin( multiFields ), std::end( multiFields ) );
|
|
|
|
|
2022-03-04 03:52:17 -06:00
|
|
|
return toolBarFields;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimSummaryMultiPlot::handleGlobalKeyEvent( QKeyEvent* keyEvent )
|
|
|
|
{
|
2022-03-10 06:13:44 -06:00
|
|
|
if ( !RimSummaryPlotControls::handleKeyEvents( m_sourceStepping(), keyEvent ) )
|
|
|
|
{
|
|
|
|
if ( isMouseCursorInsidePlot() )
|
|
|
|
{
|
|
|
|
if ( keyEvent->key() == Qt::Key_PageUp )
|
|
|
|
{
|
|
|
|
m_viewer->goToPrevPage();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if ( keyEvent->key() == Qt::Key_PageDown )
|
|
|
|
{
|
|
|
|
m_viewer->goToNextPage();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RimSummaryMultiPlot::handleGlobalWheelEvent( QWheelEvent* wheelEvent )
|
|
|
|
{
|
|
|
|
if ( m_disableWheelZoom )
|
|
|
|
{
|
|
|
|
if ( isMouseCursorInsidePlot() )
|
|
|
|
{
|
|
|
|
if ( wheelEvent->angleDelta().y() > 0 )
|
|
|
|
{
|
|
|
|
m_viewer->goToPrevPage();
|
|
|
|
}
|
|
|
|
else if ( wheelEvent->angleDelta().y() < 0 )
|
|
|
|
{
|
|
|
|
m_viewer->goToNextPage();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
2022-03-04 03:52:17 -06:00
|
|
|
}
|
2022-03-08 09:16:07 -06:00
|
|
|
|
2022-03-23 07:35:47 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimSummaryMultiPlot::initAfterRead()
|
|
|
|
{
|
|
|
|
RimMultiPlot::initAfterRead();
|
|
|
|
|
|
|
|
for ( auto plot : summaryPlots() )
|
|
|
|
{
|
2022-04-04 08:10:39 -05:00
|
|
|
plot->axisChanged.connect( this, &RimSummaryMultiPlot::onSubPlotAxisChanged );
|
2022-03-23 07:35:47 -05:00
|
|
|
plot->curvesChanged.connect( this, &RimSummaryMultiPlot::onSubPlotChanged );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-08 09:16:07 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimSummaryMultiPlot::syncAxisRanges()
|
|
|
|
{
|
|
|
|
std::map<QString, std::pair<double, double>> axisRanges;
|
|
|
|
|
2022-03-11 01:41:53 -06:00
|
|
|
// Reset zoom to make sure the complete range for min/max is available
|
|
|
|
zoomAll();
|
|
|
|
|
2022-03-08 09:16:07 -06:00
|
|
|
// gather current min/max values for each category (axis label)
|
|
|
|
for ( auto plot : summaryPlots() )
|
|
|
|
{
|
|
|
|
for ( auto axis : plot->plotAxes() )
|
|
|
|
{
|
|
|
|
double minVal = axis->visibleRangeMin();
|
|
|
|
double maxVal = axis->visibleRangeMax();
|
|
|
|
|
|
|
|
if ( axisRanges.count( axis->name() ) == 0 )
|
|
|
|
{
|
|
|
|
axisRanges[axis->name()] = std::make_pair( axis->visibleRangeMin(), axis->visibleRangeMax() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
auto& [currentMin, currentMax] = axisRanges[axis->name()];
|
|
|
|
axisRanges[axis->name()] = std::make_pair( std::min( currentMin, minVal ), std::max( currentMax, maxVal ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// set all plots to use the global min/max values for each category
|
|
|
|
for ( auto plot : summaryPlots() )
|
|
|
|
{
|
|
|
|
for ( auto axis : plot->plotAxes() )
|
|
|
|
{
|
|
|
|
const auto& [minVal, maxVal] = axisRanges[axis->name()];
|
|
|
|
axis->setAutoZoom( false );
|
|
|
|
axis->setVisibleRangeMin( minVal );
|
|
|
|
axis->setVisibleRangeMax( maxVal );
|
|
|
|
}
|
|
|
|
|
|
|
|
plot->updateAxes();
|
|
|
|
}
|
|
|
|
}
|
2022-03-16 08:14:14 -05:00
|
|
|
|
2022-03-25 05:39:12 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimSummaryMultiPlot::summaryPlotItemInfos( QList<caf::PdmOptionItemInfo>* optionInfos ) const
|
|
|
|
{
|
|
|
|
for ( RimSummaryPlot* plot : summaryPlots() )
|
|
|
|
{
|
|
|
|
QString displayName = plot->description();
|
|
|
|
optionInfos->push_back( caf::PdmOptionItemInfo( displayName, plot, false, plot->uiCapability()->uiIconProvider() ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-16 08:14:14 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimSummaryMultiPlot::duplicate()
|
|
|
|
{
|
|
|
|
duplicatePlot.send( this );
|
|
|
|
}
|
2022-03-23 07:35:47 -05:00
|
|
|
|
2022-04-07 09:24:27 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimSummaryMultiPlot::makeSureIsVisible( RimSummaryPlot* summaryPlot )
|
|
|
|
{
|
|
|
|
if ( summaryPlot->plotWidget() && !m_viewer.isNull() ) m_viewer->scrollToPlot( summaryPlot->plotWidget() );
|
|
|
|
}
|
|
|
|
|
2022-03-23 07:35:47 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimSummaryMultiPlot::onSubPlotChanged( const caf::SignalEmitter* emitter )
|
|
|
|
{
|
|
|
|
updatePlotWindowTitle();
|
|
|
|
applyPlotWindowTitleToWidgets();
|
|
|
|
}
|
2022-04-04 08:10:39 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimSummaryMultiPlot::onSubPlotAxisChanged( const caf::SignalEmitter* emitter, RimSummaryPlot* summaryPlot )
|
|
|
|
{
|
|
|
|
if ( !m_syncSubPlotAxes() ) return;
|
|
|
|
|
|
|
|
for ( auto plot : summaryPlots() )
|
|
|
|
{
|
|
|
|
if ( plot != summaryPlot )
|
|
|
|
{
|
|
|
|
plot->copyMatchingAxisPropertiesFromOther( *summaryPlot );
|
|
|
|
plot->updateAll();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|