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-01-07 01:31:52 -06:00
|
|
|
CAF_PDM_InitObject( "Multi Summary Plot" );
|
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-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 )
|
|
|
|
{
|
|
|
|
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
|
|
|
addPlot( plot );
|
2022-03-15 09:57:15 -05:00
|
|
|
|
2022-03-16 08:14:14 -05:00
|
|
|
plot->handleDroppedObjects( objects );
|
|
|
|
}
|
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-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-03-04 03:52:17 -06:00
|
|
|
caf::PdmUiGroup* titlesGroup = uiOrdering.addNewGroup( "Titles" );
|
|
|
|
titlesGroup->add( &m_autoPlotTitles );
|
|
|
|
titlesGroup->add( &m_autoPlotTitlesOnSubPlots );
|
|
|
|
|
|
|
|
titlesGroup->add( &m_showPlotWindowTitle );
|
|
|
|
titlesGroup->add( &m_plotWindowTitle );
|
|
|
|
titlesGroup->add( &m_showIndividualPlotTitles );
|
|
|
|
titlesGroup->add( &m_titleFontSize );
|
|
|
|
titlesGroup->add( &m_subTitleFontSize );
|
|
|
|
|
|
|
|
caf::PdmUiGroup* legendsGroup = uiOrdering.addNewGroup( "Legends" );
|
|
|
|
legendsGroup->add( &m_showPlotLegends );
|
|
|
|
legendsGroup->add( &m_plotLegendsHorizontal );
|
|
|
|
legendsGroup->add( &m_legendFontSize );
|
|
|
|
|
|
|
|
caf::PdmUiGroup* layoutGroup = uiOrdering.addNewGroup( "Layout" );
|
|
|
|
layoutGroup->add( &m_columnCount );
|
|
|
|
layoutGroup->add( &m_rowsPerPage );
|
|
|
|
layoutGroup->add( &m_majorTickmarkCount );
|
|
|
|
|
|
|
|
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-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();
|
|
|
|
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
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimSummaryMultiPlot::insertGraphsIntoPlot( RimSummaryMultiPlot* plot, const std::vector<RimSummaryPlot*>& graphs )
|
|
|
|
{
|
|
|
|
auto columnCount = RiuMultiPlotPage::ColumnCount::COLUMNS_2;
|
|
|
|
auto rowCount = RimMultiPlot::RowCount::ROWS_2;
|
|
|
|
auto tickmarkCount = RimPlotAxisPropertiesInterface::LegendTickmarkCount::TICKMARK_DEFAULT;
|
|
|
|
|
|
|
|
bool showTitleSubGraph = true;
|
|
|
|
if ( graphs.size() == 1 )
|
|
|
|
{
|
|
|
|
showTitleSubGraph = false;
|
|
|
|
tickmarkCount = RimPlotAxisPropertiesInterface::LegendTickmarkCount::TICKMARK_MANY;
|
|
|
|
}
|
|
|
|
else if ( 4 < graphs.size() && graphs.size() <= 6 )
|
|
|
|
{
|
|
|
|
columnCount = RiuMultiPlotPage::ColumnCount::COLUMNS_3;
|
|
|
|
rowCount = RimMultiPlot::RowCount::ROWS_2;
|
|
|
|
tickmarkCount = RimPlotAxisPropertiesInterface::LegendTickmarkCount::TICKMARK_FEW;
|
|
|
|
}
|
|
|
|
else if ( 6 < graphs.size() && graphs.size() <= 12 )
|
|
|
|
{
|
|
|
|
columnCount = RiuMultiPlotPage::ColumnCount::COLUMNS_4;
|
|
|
|
rowCount = RimMultiPlot::RowCount::ROWS_3;
|
|
|
|
tickmarkCount = RimPlotAxisPropertiesInterface::LegendTickmarkCount::TICKMARK_VERY_FEW;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
columnCount = RiuMultiPlotPage::ColumnCount::COLUMNS_4;
|
|
|
|
rowCount = RimMultiPlot::RowCount::ROWS_4;
|
|
|
|
tickmarkCount = RimPlotAxisPropertiesInterface::LegendTickmarkCount::TICKMARK_VERY_FEW;
|
|
|
|
}
|
|
|
|
|
|
|
|
plot->setAutoTitlePlot( true );
|
|
|
|
plot->setAutoTitleGraphs( showTitleSubGraph );
|
|
|
|
|
2022-03-04 03:52:17 -06:00
|
|
|
plot->setColumnCount( columnCount );
|
|
|
|
plot->setRowCount( rowCount );
|
|
|
|
plot->setShowPlotTitles( showTitleSubGraph );
|
|
|
|
plot->setTickmarkCount( tickmarkCount );
|
2022-01-10 07:51:31 -06:00
|
|
|
|
|
|
|
for ( auto graph : graphs )
|
|
|
|
{
|
|
|
|
plot->addPlot( graph );
|
|
|
|
|
|
|
|
graph->resolveReferencesRecursively();
|
|
|
|
graph->revokeMdiWindowStatus();
|
|
|
|
graph->setShowWindow( true );
|
|
|
|
|
|
|
|
graph->loadDataAndUpdate();
|
|
|
|
}
|
|
|
|
|
|
|
|
plot->loadDataAndUpdate();
|
|
|
|
}
|
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 ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
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
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimSummaryMultiPlot::duplicate()
|
|
|
|
{
|
|
|
|
duplicatePlot.send( this );
|
|
|
|
}
|