mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 23:20:29 -05:00
SummaryMultiPlot: Improve sub-plot stepping and duplicate plot handling
This commit is contained in:
1 parent
4586df88fe
commit
6ff75e3700
6 files changed
+136
-105
No files matched your search
@@ -112,7 +112,6 @@ void RimSummaryMultiPlot::clearLayoutInfo()
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryMultiPlot::RimSummaryMultiPlot()
|
||||
: duplicatePlot( this )
|
||||
{
|
||||
CAF_PDM_InitObject( "Multi Summary Plot", ":/SummaryPlotLight16x16.png" );
|
||||
setDeletable( true );
|
||||
@@ -492,7 +491,10 @@ void RimSummaryMultiPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedFi
|
||||
else if ( changedField == &m_createPlotDuplicate )
|
||||
{
|
||||
m_createPlotDuplicate = false;
|
||||
duplicate();
|
||||
if ( auto plotCollection = RimMainPlotCollection::current()->summaryMultiPlotCollection() )
|
||||
{
|
||||
plotCollection->duplicatePlot( this );
|
||||
}
|
||||
}
|
||||
else if ( changedField == &m_appendNextPlot )
|
||||
{
|
||||
@@ -689,6 +691,8 @@ std::vector<caf::PdmFieldHandle*> RimSummaryMultiPlot::fieldsToShowInToolbar()
|
||||
auto& sourceObject = m_sourceStepping();
|
||||
if ( sourceObject )
|
||||
{
|
||||
sourceObject->setSourceSteppingObject( steppingSourceObject() );
|
||||
|
||||
auto fields = sourceObject->fieldsToShowInToolbar();
|
||||
toolBarFields.insert( std::end( toolBarFields ), std::begin( fields ), std::end( fields ) );
|
||||
}
|
||||
@@ -1302,14 +1306,6 @@ void RimSummaryMultiPlot::summaryPlotItemInfos( QList<caf::PdmOptionItemInfo>* o
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryMultiPlot::duplicate()
|
||||
{
|
||||
duplicatePlot.send( this );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1611,91 +1607,151 @@ void RimSummaryMultiPlot::onPlotAdditionOrRemoval()
|
||||
RimMultiPlot::onPlotAdditionOrRemoval();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimSummaryMultiPlot::isStepDimensionSharedAmongSubPlots()
|
||||
{
|
||||
using Dim = RimSummaryDataSourceStepping::SourceSteppingDimension;
|
||||
|
||||
populateNameHelper( m_nameHelper.get() );
|
||||
|
||||
switch ( m_sourceStepping->stepDimension() )
|
||||
{
|
||||
case Dim::SUMMARY_CASE:
|
||||
case Dim::ENSEMBLE:
|
||||
return m_nameHelper->isCaseInTitle();
|
||||
case Dim::WELL:
|
||||
return m_nameHelper->isWellNameInTitle();
|
||||
case Dim::GROUP:
|
||||
return m_nameHelper->isGroupNameInTitle();
|
||||
case Dim::NETWORK:
|
||||
return m_nameHelper->isNetworkInTitle();
|
||||
case Dim::REGION:
|
||||
return m_nameHelper->isRegionInTitle();
|
||||
case Dim::VECTOR:
|
||||
return !m_nameHelper->titleVectorName().empty();
|
||||
case Dim::BLOCK:
|
||||
return m_nameHelper->isBlockInTitle();
|
||||
case Dim::WELL_SEGMENT:
|
||||
return m_nameHelper->isSegmentInTitle();
|
||||
case Dim::WELL_CONNECTION:
|
||||
return m_nameHelper->isConnectionInTitle();
|
||||
case Dim::WELL_COMPLETION_NUMBER:
|
||||
return m_nameHelper->isWellCompletionInTitle();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmObject* RimSummaryMultiPlot::steppingSourceObject()
|
||||
{
|
||||
if ( !isStepDimensionSharedAmongSubPlots() )
|
||||
{
|
||||
auto* selectedPlot = caf::SelectionManager::instance()->selectedItemOfType<RimSummaryPlot>();
|
||||
if ( selectedPlot && selectedPlot->firstAncestorOrThisOfType<RimSummaryMultiPlot>() == this ) return selectedPlot;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryMultiPlot::appendSubPlotByStepping( int direction )
|
||||
{
|
||||
std::vector<RimSummaryPlot*> plotsForStepping;
|
||||
m_sourceStepping->setSourceSteppingObject( steppingSourceObject() );
|
||||
|
||||
bool isMultiPlotSelected = ( caf::SelectionManager::instance()->selectedItemOfType<RimSummaryMultiPlot>() != nullptr );
|
||||
if ( isMultiPlotSelected )
|
||||
auto applySteppingToPlots = []( const std::vector<RimSummaryPlot*>& summaryPlots, RimSummaryPlotSourceStepping* sourceStepper, int direction )
|
||||
{
|
||||
duplicate();
|
||||
if ( !sourceStepper ) return;
|
||||
|
||||
// The duplicate operation selects duplicated plot by default. Select this as current item to continue stepping on this plot
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem( this );
|
||||
for ( auto newPlot : summaryPlots )
|
||||
{
|
||||
if ( sourceStepper->stepDimension() == RimSummaryDataSourceStepping::SourceSteppingDimension::SUMMARY_CASE )
|
||||
{
|
||||
RimSummaryCase* newCase = sourceStepper->stepCase( direction );
|
||||
for ( auto curve : newPlot->allCurves() )
|
||||
{
|
||||
curve->setSummaryCaseY( newCase );
|
||||
|
||||
plotsForStepping = summaryPlots();
|
||||
// NOTE: If summary cross plots should be handled here, we also need to call
|
||||
// curve->setSummaryCaseX( newCase );
|
||||
// Setting summaryCaseX with a default uninitialized summary address causes issues for the summary
|
||||
// name analyzer
|
||||
}
|
||||
}
|
||||
else if ( sourceStepper->stepDimension() == RimSummaryDataSourceStepping::SourceSteppingDimension::ENSEMBLE )
|
||||
{
|
||||
RimSummaryEnsemble* newEnsemble = sourceStepper->stepEnsemble( direction );
|
||||
for ( auto curveSet : newPlot->curveSets() )
|
||||
{
|
||||
curveSet->setSummaryEnsemble( newEnsemble );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<RiaSummaryCurveAddress> newCurveAdrs;
|
||||
|
||||
auto curveAddressProviders = RiaSummaryAddressModifier::createAddressProviders( newPlot );
|
||||
for ( const auto& adr : RiaSummaryAddressModifier::curveAddresses( curveAddressProviders ) )
|
||||
{
|
||||
const auto adrX = sourceStepper->stepAddress( adr.summaryAddressX(), direction );
|
||||
const auto adrY = sourceStepper->stepAddress( adr.summaryAddressY(), direction );
|
||||
newCurveAdrs.push_back( RiaSummaryCurveAddress( adrX, adrY ) );
|
||||
}
|
||||
|
||||
RiaSummaryAddressModifier::applyAddressesToCurveAddressProviders( curveAddressProviders, newCurveAdrs );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if ( m_sourceStepping()->isAtEnd( direction ) ) return;
|
||||
|
||||
if ( caf::SelectionManager::instance()->selectedItemOfType<RimSummaryMultiPlot>() != nullptr )
|
||||
{
|
||||
if ( auto plotCollection = RimMainPlotCollection::current()->summaryMultiPlotCollection() )
|
||||
{
|
||||
auto copy = plotCollection->duplicatePlot( this );
|
||||
|
||||
applySteppingToPlots( copy->summaryPlots(), m_sourceStepping(), direction );
|
||||
|
||||
copy->loadDataAndUpdate();
|
||||
copy->updateConnectedEditors();
|
||||
copy->updateSourceStepper();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<RimPlot*> plots = m_sourceStepping->plotsMatchingStepSettings( summaryPlots() );
|
||||
if ( !plots.empty() )
|
||||
{
|
||||
auto newPlots = RiaSummaryPlotTools::duplicatePlots( plots );
|
||||
std::vector<RimSummaryPlot*> summaryPlots;
|
||||
auto newPlots = RiaSummaryPlotTools::duplicatePlots( plots );
|
||||
for ( auto plot : newPlots )
|
||||
{
|
||||
if ( RimSummaryPlot* newPlot = dynamic_cast<RimSummaryPlot*>( plot ) )
|
||||
{
|
||||
addPlot( newPlot );
|
||||
newPlot->resolveReferencesRecursively();
|
||||
|
||||
plotsForStepping.push_back( newPlot );
|
||||
summaryPlots.push_back( newPlot );
|
||||
}
|
||||
}
|
||||
applySteppingToPlots( summaryPlots, m_sourceStepping(), direction );
|
||||
}
|
||||
}
|
||||
|
||||
for ( auto newPlot : plotsForStepping )
|
||||
{
|
||||
if ( m_sourceStepping()->stepDimension() == RimSummaryDataSourceStepping::SourceSteppingDimension::SUMMARY_CASE )
|
||||
{
|
||||
RimSummaryCase* newCase = m_sourceStepping()->stepCase( direction );
|
||||
for ( auto curve : newPlot->allCurves() )
|
||||
{
|
||||
curve->setSummaryCaseY( newCase );
|
||||
loadDataAndUpdate();
|
||||
updateConnectedEditors();
|
||||
|
||||
// NOTE: If summary cross plots should be handled here, we also need to call
|
||||
// curve->setSummaryCaseX( newCase );
|
||||
// Setting summaryCaseX with a default uninitialized summary address causes issues for the summary
|
||||
// name analyzer
|
||||
}
|
||||
}
|
||||
else if ( m_sourceStepping()->stepDimension() == RimSummaryDataSourceStepping::SourceSteppingDimension::ENSEMBLE )
|
||||
{
|
||||
RimSummaryEnsemble* newEnsemble = m_sourceStepping()->stepEnsemble( direction );
|
||||
for ( auto curveSet : newPlot->curveSets() )
|
||||
{
|
||||
curveSet->setSummaryEnsemble( newEnsemble );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<RiaSummaryCurveAddress> newCurveAdrs;
|
||||
|
||||
auto curveAddressProviders = RiaSummaryAddressModifier::createAddressProviders( newPlot );
|
||||
for ( const auto& adr : RiaSummaryAddressModifier::curveAddresses( curveAddressProviders ) )
|
||||
{
|
||||
const auto adrX = m_sourceStepping()->stepAddress( adr.summaryAddressX(), direction );
|
||||
const auto adrY = m_sourceStepping()->stepAddress( adr.summaryAddressY(), direction );
|
||||
newCurveAdrs.push_back( RiaSummaryCurveAddress( adrX, adrY ) );
|
||||
}
|
||||
|
||||
RiaSummaryAddressModifier::applyAddressesToCurveAddressProviders( curveAddressProviders, newCurveAdrs );
|
||||
}
|
||||
}
|
||||
|
||||
loadDataAndUpdate();
|
||||
updateConnectedEditors();
|
||||
|
||||
if ( !isMultiPlotSelected && !summaryPlots().empty() )
|
||||
{
|
||||
// Select the last plot in the list as the current item to be able to append plots for the next object type (well, region, etc.)
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem( summaryPlots().back() );
|
||||
|
||||
updateSourceStepper();
|
||||
}
|
||||
|
||||
updateSourceStepper();
|
||||
RiuPlotMainWindowTools::refreshToolbars();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user