mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#6189 Add check box on ensemble level in summary vector dialog
This commit is contained in:
parent
7241132256
commit
6f50201e3a
@ -415,7 +415,6 @@ void RimAnalysisPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
|
||||
dlg.enableMultiSelect( true );
|
||||
dlg.enableIndividualEnsembleCaseSelection( true );
|
||||
|
||||
dlg.setCurveSelection( this->curveDefinitionsWithoutEnsembleReference() );
|
||||
|
||||
if ( dlg.exec() == QDialog::Accepted )
|
||||
|
@ -43,6 +43,8 @@
|
||||
#include "cafPdmUiFieldHandle.h"
|
||||
#include "cafPdmUiTreeSelectionEditor.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RiuSummaryVectorSelectionUi, "RicSummaryAddressSelection" );
|
||||
@ -644,6 +646,7 @@ void RiuSummaryVectorSelectionUi::setSelectedCurveDefinitions( const std::vector
|
||||
if ( summaryCase != calculatedSummaryCase() )
|
||||
{
|
||||
m_selectedSources.push_back( summSource );
|
||||
handleAddedSource( summSource );
|
||||
}
|
||||
}
|
||||
|
||||
@ -684,6 +687,8 @@ void RiuSummaryVectorSelectionUi::setSelectedCurveDefinitions( const std::vector
|
||||
RifEclipseSummaryAddress::SummaryVarCategory cat = *( categories.begin() );
|
||||
m_currentSummaryCategory.setValue( cat );
|
||||
}
|
||||
|
||||
m_previouslySelectedSources = m_selectedSources.ptrReferencedObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -714,6 +719,35 @@ void RiuSummaryVectorSelectionUi::fieldChangedByUi( const caf::PdmFieldHandle* c
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue )
|
||||
{
|
||||
if ( changedField == &m_selectedSources )
|
||||
{
|
||||
caf::PdmObject* objectAdded = nullptr;
|
||||
for ( caf::PdmObject* selectedObject : m_selectedSources() )
|
||||
{
|
||||
auto it = std::find( m_previouslySelectedSources.begin(), m_previouslySelectedSources.end(), selectedObject );
|
||||
if ( it == m_previouslySelectedSources.end() )
|
||||
{
|
||||
objectAdded = selectedObject;
|
||||
handleAddedSource( objectAdded );
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( !objectAdded )
|
||||
{
|
||||
caf::PdmObject* objectRemoved = nullptr;
|
||||
for ( caf::PdmObject* previouslySelectedObject : m_previouslySelectedSources )
|
||||
{
|
||||
auto it = std::find( m_selectedSources.begin(), m_selectedSources.end(), previouslySelectedObject );
|
||||
if ( it == m_selectedSources.end() )
|
||||
{
|
||||
objectRemoved = previouslySelectedObject;
|
||||
handleRemovedSource( objectRemoved );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
m_previouslySelectedSources = m_selectedSources.ptrReferencedObjects();
|
||||
}
|
||||
if ( changedField != &m_selectedSources && changedField != &m_selectedSummaryCategories &&
|
||||
changedField != &m_currentSummaryCategory )
|
||||
{
|
||||
@ -1262,6 +1296,7 @@ void RiuSummaryVectorSelectionUi::defineEditorAttribute( const caf::PdmFieldHand
|
||||
void RiuSummaryVectorSelectionUi::resetAllFields()
|
||||
{
|
||||
m_selectedSources.clear();
|
||||
m_previouslySelectedSources.clear();
|
||||
m_selectedSummaryCategories = std::vector<caf::AppEnum<RifEclipseSummaryAddress::SummaryVarCategory>>();
|
||||
|
||||
// clear all state in fields
|
||||
@ -1349,20 +1384,14 @@ void RiuSummaryVectorSelectionUi::appendOptionItemsForSources( QList<caf::PdmOpt
|
||||
options.push_back( caf::PdmOptionItemInfo::createHeader( "Ensembles", true ) );
|
||||
ensembleHeaderCreated = true;
|
||||
}
|
||||
|
||||
if ( !m_showIndividualEnsembleCases )
|
||||
// Ensemble level
|
||||
{
|
||||
auto optionItem = caf::PdmOptionItemInfo( sumCaseColl->name(), sumCaseColl );
|
||||
optionItem.setLevel( 1 );
|
||||
options.push_back( optionItem );
|
||||
}
|
||||
else
|
||||
if ( m_showIndividualEnsembleCases )
|
||||
{
|
||||
caf::PdmOptionItemInfo ensembleOpt =
|
||||
caf::PdmOptionItemInfo::createHeader( sumCaseColl->name(), true );
|
||||
ensembleOpt.setLevel( 1 );
|
||||
options.push_back( ensembleOpt );
|
||||
|
||||
for ( const auto& sumCase : sumCaseColl->allSummaryCases() )
|
||||
{
|
||||
auto optionItem = caf::PdmOptionItemInfo( sumCase->displayCaseName(), sumCase );
|
||||
@ -1577,3 +1606,91 @@ void RiuSummaryVectorSelectionUi::appendOptionItemsForSubCategoriesAndVectors( Q
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSummaryVectorSelectionUi::handleAddedSource( SummarySource* sourceAdded )
|
||||
{
|
||||
CAF_ASSERT( sourceAdded );
|
||||
auto caseCollection = dynamic_cast<RimSummaryCaseCollection*>( sourceAdded );
|
||||
if ( caseCollection )
|
||||
{
|
||||
// Select all children
|
||||
for ( auto summaryCase : caseCollection->allSummaryCases() )
|
||||
{
|
||||
auto it = std::find( m_selectedSources.begin(), m_selectedSources.end(), summaryCase );
|
||||
if ( it == m_selectedSources.end() )
|
||||
{
|
||||
m_selectedSources.push_back( summaryCase );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auto summaryCase = dynamic_cast<RimSummaryCase*>( sourceAdded );
|
||||
if ( summaryCase )
|
||||
{
|
||||
auto caseCollection = summaryCase->ensemble();
|
||||
if ( caseCollection )
|
||||
{
|
||||
auto it = std::find( m_selectedSources.begin(), m_selectedSources.end(), caseCollection );
|
||||
if ( it == m_selectedSources.end() )
|
||||
{
|
||||
// Check if all children have been selected.
|
||||
bool allChildrenSelected = true;
|
||||
for ( auto summaryChild : caseCollection->allSummaryCases() )
|
||||
{
|
||||
auto it = std::find( m_selectedSources.begin(), m_selectedSources.end(), summaryChild );
|
||||
if ( it == m_selectedSources.end() )
|
||||
{
|
||||
allChildrenSelected = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( allChildrenSelected ) // Add collection if all children have been selected
|
||||
{
|
||||
m_selectedSources.push_back( caseCollection );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuSummaryVectorSelectionUi::handleRemovedSource( SummarySource* sourceRemoved )
|
||||
{
|
||||
CAF_ASSERT( sourceRemoved );
|
||||
auto caseCollection = dynamic_cast<RimSummaryCaseCollection*>( sourceRemoved );
|
||||
if ( caseCollection )
|
||||
{
|
||||
// Select all children
|
||||
for ( auto summaryCase : caseCollection->allSummaryCases() )
|
||||
{
|
||||
auto it = std::find( m_selectedSources.begin(), m_selectedSources.end(), summaryCase );
|
||||
if ( it != m_selectedSources.end() )
|
||||
{
|
||||
m_selectedSources.removePtr( *it );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auto summaryCase = dynamic_cast<RimSummaryCase*>( sourceRemoved );
|
||||
if ( summaryCase )
|
||||
{
|
||||
auto caseCollection = summaryCase->ensemble();
|
||||
if ( caseCollection )
|
||||
{
|
||||
auto it = std::find( m_selectedSources.begin(), m_selectedSources.end(), caseCollection );
|
||||
if ( it != m_selectedSources.end() )
|
||||
{
|
||||
m_selectedSources.removePtr( *it );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -111,8 +111,12 @@ private:
|
||||
void appendOptionItemsForSubCategoriesAndVectors( QList<caf::PdmOptionItemInfo>& options,
|
||||
SummaryIdentifierAndField* identifierAndField ) const;
|
||||
|
||||
void handleAddedSource( SummarySource* sourceAdded );
|
||||
void handleRemovedSource( SummarySource* sourceRemoved );
|
||||
|
||||
private:
|
||||
caf::PdmPtrArrayField<SummarySource*> m_selectedSources;
|
||||
std::vector<SummarySource*> m_previouslySelectedSources;
|
||||
|
||||
caf::PdmField<std::vector<caf::AppEnum<RifEclipseSummaryAddress::SummaryVarCategory>>> m_selectedSummaryCategories;
|
||||
caf::PdmField<caf::AppEnum<RifEclipseSummaryAddress::SummaryVarCategory>> m_currentSummaryCategory;
|
||||
|
Loading…
Reference in New Issue
Block a user