2017-09-08 07:49:41 -05:00
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016 Statoil 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.
//
/////////////////////////////////////////////////////////////////////////////////
2017-09-12 04:58:49 -05:00
# include <sstream>
2017-09-08 07:49:41 -05:00
# include "RicSummaryCurveCreator.h"
# include "RiaApplication.h"
# include "RifReaderEclipseSummary.h"
# include "RigSummaryCaseData.h"
# include "RimProject.h"
# include "RimSummaryCase.h"
# include "RimSummaryCase.h"
# include "cafPdmUiListEditor.h"
2017-09-12 04:58:49 -05:00
# include "cafPdmUiTreeSelectionEditor.h"
2017-09-12 12:51:45 -05:00
# include "RimSummaryPlot.h"
2017-09-08 07:49:41 -05:00
CAF_PDM_SOURCE_INIT ( RicSummaryCurveCreator , " RicSummaryCurveCreator " ) ;
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-09-12 12:51:45 -05:00
RicSummaryCurveCreator : : RicSummaryCurveCreator ( ) : m_selectedIdentifiers (
2017-09-08 07:49:41 -05:00
{
2017-09-12 12:51:45 -05:00
{ RifEclipseSummaryAddress : : SUMMARY_FIELD , {
{ new SummaryIdentifierAndField ( INPUT_VECTOR_NAME ) }
2017-09-12 04:58:49 -05:00
} } ,
2017-09-12 12:51:45 -05:00
{ RifEclipseSummaryAddress : : SUMMARY_AQUIFER , {
{ new SummaryIdentifierAndField ( INPUT_VECTOR_NAME ) }
2017-09-12 04:58:49 -05:00
} } ,
2017-09-12 12:51:45 -05:00
{ RifEclipseSummaryAddress : : SUMMARY_NETWORK , {
{ new SummaryIdentifierAndField ( INPUT_VECTOR_NAME ) }
2017-09-12 04:58:49 -05:00
} } ,
2017-09-12 12:51:45 -05:00
{ RifEclipseSummaryAddress : : SUMMARY_MISC , {
{ new SummaryIdentifierAndField ( INPUT_VECTOR_NAME ) }
2017-09-12 04:58:49 -05:00
} } ,
2017-09-12 12:51:45 -05:00
{ RifEclipseSummaryAddress : : SUMMARY_REGION , {
{ new SummaryIdentifierAndField ( INPUT_REGION_NUMBER ) } ,
{ new SummaryIdentifierAndField ( INPUT_VECTOR_NAME ) }
2017-09-08 07:49:41 -05:00
} } ,
2017-09-12 12:51:45 -05:00
{ RifEclipseSummaryAddress : : SUMMARY_REGION_2_REGION , {
{ new SummaryIdentifierAndField ( INPUT_REGION_NUMBER ) } ,
{ new SummaryIdentifierAndField ( INPUT_REGION2_NUMBER ) } ,
{ new SummaryIdentifierAndField ( INPUT_VECTOR_NAME ) }
2017-09-08 07:49:41 -05:00
} } ,
2017-09-12 12:51:45 -05:00
{ RifEclipseSummaryAddress : : SUMMARY_WELL_GROUP , {
{ new SummaryIdentifierAndField ( INPUT_WELL_GROUP_NAME ) } ,
{ new SummaryIdentifierAndField ( INPUT_VECTOR_NAME ) }
2017-09-08 07:49:41 -05:00
} } ,
2017-09-12 12:51:45 -05:00
{ RifEclipseSummaryAddress : : SUMMARY_WELL , {
{ new SummaryIdentifierAndField ( INPUT_WELL_NAME ) } ,
{ new SummaryIdentifierAndField ( INPUT_VECTOR_NAME ) }
2017-09-08 07:49:41 -05:00
} } ,
2017-09-12 12:51:45 -05:00
{ RifEclipseSummaryAddress : : SUMMARY_WELL_COMPLETION , {
{ new SummaryIdentifierAndField ( INPUT_WELL_NAME ) } ,
{ new SummaryIdentifierAndField ( INPUT_CELL_IJK ) } ,
{ new SummaryIdentifierAndField ( INPUT_VECTOR_NAME ) }
2017-09-08 07:49:41 -05:00
} } ,
2017-09-12 12:51:45 -05:00
{ RifEclipseSummaryAddress : : SUMMARY_WELL_COMPLETION_LGR , {
{ new SummaryIdentifierAndField ( INPUT_LGR_NAME ) } ,
{ new SummaryIdentifierAndField ( INPUT_WELL_NAME ) } ,
{ new SummaryIdentifierAndField ( INPUT_CELL_IJK ) } ,
{ new SummaryIdentifierAndField ( INPUT_VECTOR_NAME ) }
2017-09-08 07:49:41 -05:00
} } ,
2017-09-12 12:51:45 -05:00
{ RifEclipseSummaryAddress : : SUMMARY_WELL_LGR , {
{ new SummaryIdentifierAndField ( INPUT_LGR_NAME ) } ,
{ new SummaryIdentifierAndField ( INPUT_WELL_NAME ) } ,
{ new SummaryIdentifierAndField ( INPUT_VECTOR_NAME ) }
2017-09-08 07:49:41 -05:00
} } ,
2017-09-12 12:51:45 -05:00
{ RifEclipseSummaryAddress : : SUMMARY_WELL_SEGMENT , {
{ new SummaryIdentifierAndField ( INPUT_WELL_NAME ) } ,
{ new SummaryIdentifierAndField ( INPUT_SEGMENT_NUMBER ) } ,
{ new SummaryIdentifierAndField ( INPUT_VECTOR_NAME ) }
2017-09-08 07:49:41 -05:00
} } ,
2017-09-12 12:51:45 -05:00
{ RifEclipseSummaryAddress : : SUMMARY_BLOCK , {
{ new SummaryIdentifierAndField ( INPUT_CELL_IJK ) } ,
{ new SummaryIdentifierAndField ( INPUT_VECTOR_NAME ) }
2017-09-08 07:49:41 -05:00
} } ,
2017-09-12 12:51:45 -05:00
{ RifEclipseSummaryAddress : : SUMMARY_BLOCK_LGR , {
{ new SummaryIdentifierAndField ( INPUT_LGR_NAME ) } ,
{ new SummaryIdentifierAndField ( INPUT_CELL_IJK ) } ,
{ new SummaryIdentifierAndField ( INPUT_VECTOR_NAME ) }
2017-09-08 07:49:41 -05:00
} }
} )
{
//CAF_PDM_InitObject("Curve Filter", ":/SummaryCurveFilter16x16.png", "", "");
CAF_PDM_InitFieldNoDefault ( & m_selectedCases , " SummaryCases " , " Cases " , " " , " " , " " ) ;
2017-09-12 12:51:45 -05:00
CAF_PDM_InitFieldNoDefault ( & m_selectedSummaryCategory , " IdentifierTypes " , " Identifier types " , " " , " " , " " ) ;
2017-09-12 04:58:49 -05:00
2017-09-12 12:51:45 -05:00
CAF_PDM_InitFieldNoDefault ( m_selectedIdentifiers [ RifEclipseSummaryAddress : : SUMMARY_FIELD ] [ 0 ] - > pdmField ( ) , " FieldVectors " , " Field vectors " , " " , " " , " " ) ;
2017-09-12 04:58:49 -05:00
2017-09-12 12:51:45 -05:00
CAF_PDM_InitFieldNoDefault ( m_selectedIdentifiers [ RifEclipseSummaryAddress : : SUMMARY_AQUIFER ] [ 0 ] - > pdmField ( ) , " AquiferVectors " , " Aquifer vectors " , " " , " " , " " ) ;
2017-09-12 04:58:49 -05:00
2017-09-12 12:51:45 -05:00
CAF_PDM_InitFieldNoDefault ( m_selectedIdentifiers [ RifEclipseSummaryAddress : : SUMMARY_NETWORK ] [ 0 ] - > pdmField ( ) , " NetworkVectors " , " Network vectors " , " " , " " , " " ) ;
2017-09-12 04:58:49 -05:00
2017-09-12 12:51:45 -05:00
CAF_PDM_InitFieldNoDefault ( m_selectedIdentifiers [ RifEclipseSummaryAddress : : SUMMARY_MISC ] [ 0 ] - > pdmField ( ) , " MiscVectors " , " Misc vectors " , " " , " " , " " ) ;
2017-09-08 07:49:41 -05:00
2017-09-12 12:51:45 -05:00
CAF_PDM_InitFieldNoDefault ( m_selectedIdentifiers [ RifEclipseSummaryAddress : : SUMMARY_REGION ] [ 0 ] - > pdmField ( ) , " Regions " , " Regions " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_selectedIdentifiers [ RifEclipseSummaryAddress : : SUMMARY_REGION ] [ 1 ] - > pdmField ( ) , " RegionsVectors " , " Regions vectors " , " " , " " , " " ) ;
2017-09-08 07:49:41 -05:00
2017-09-12 12:51:45 -05:00
CAF_PDM_InitFieldNoDefault ( m_selectedIdentifiers [ RifEclipseSummaryAddress : : SUMMARY_REGION_2_REGION ] [ 0 ] - > pdmField ( ) , " Region2RegionRegions " , " Regions " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_selectedIdentifiers [ RifEclipseSummaryAddress : : SUMMARY_REGION_2_REGION ] [ 1 ] - > pdmField ( ) , " Region2RegionRegion2s " , " Region2s " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_selectedIdentifiers [ RifEclipseSummaryAddress : : SUMMARY_REGION_2_REGION ] [ 2 ] - > pdmField ( ) , " Region2RegionVectors " , " Region2s vectors " , " " , " " , " " ) ;
2017-09-08 07:49:41 -05:00
2017-09-12 12:51:45 -05:00
CAF_PDM_InitFieldNoDefault ( m_selectedIdentifiers [ RifEclipseSummaryAddress : : SUMMARY_WELL_GROUP ] [ 0 ] - > pdmField ( ) , " WellGroupWellGroupNames " , " Well groups " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_selectedIdentifiers [ RifEclipseSummaryAddress : : SUMMARY_WELL_GROUP ] [ 1 ] - > pdmField ( ) , " WellGroupVectors " , " Well group vectors " , " " , " " , " " ) ;
2017-09-08 07:49:41 -05:00
2017-09-12 12:51:45 -05:00
CAF_PDM_InitFieldNoDefault ( m_selectedIdentifiers [ RifEclipseSummaryAddress : : SUMMARY_WELL ] [ 0 ] - > pdmField ( ) , " WellWellName " , " Wells " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_selectedIdentifiers [ RifEclipseSummaryAddress : : SUMMARY_WELL ] [ 1 ] - > pdmField ( ) , " WellVectors " , " Well vectors " , " " , " " , " " ) ;
2017-09-08 07:49:41 -05:00
2017-09-12 12:51:45 -05:00
CAF_PDM_InitFieldNoDefault ( m_selectedIdentifiers [ RifEclipseSummaryAddress : : SUMMARY_WELL_COMPLETION ] [ 0 ] - > pdmField ( ) , " WellCompletionWellName " , " Wells " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_selectedIdentifiers [ RifEclipseSummaryAddress : : SUMMARY_WELL_COMPLETION ] [ 1 ] - > pdmField ( ) , " WellCompletionIjk " , " Cell IJK " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_selectedIdentifiers [ RifEclipseSummaryAddress : : SUMMARY_WELL_COMPLETION ] [ 2 ] - > pdmField ( ) , " WellCompletionVectors " , " Well completion vectors " , " " , " " , " " ) ;
2017-09-08 07:49:41 -05:00
2017-09-12 12:51:45 -05:00
CAF_PDM_InitFieldNoDefault ( m_selectedIdentifiers [ RifEclipseSummaryAddress : : SUMMARY_WELL_COMPLETION_LGR ] [ 0 ] - > pdmField ( ) , " WellCompletionLgrLgrName " , " Lgr names " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_selectedIdentifiers [ RifEclipseSummaryAddress : : SUMMARY_WELL_COMPLETION_LGR ] [ 1 ] - > pdmField ( ) , " WellCompletionLgrWellName " , " Wells " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_selectedIdentifiers [ RifEclipseSummaryAddress : : SUMMARY_WELL_COMPLETION_LGR ] [ 2 ] - > pdmField ( ) , " WellCompletionLgrIjk " , " Cell IJK " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_selectedIdentifiers [ RifEclipseSummaryAddress : : SUMMARY_WELL_COMPLETION_LGR ] [ 3 ] - > pdmField ( ) , " WellCompletionLgrVectors " , " Well completion vectors " , " " , " " , " " ) ;
2017-09-08 07:49:41 -05:00
2017-09-12 12:51:45 -05:00
CAF_PDM_InitFieldNoDefault ( m_selectedIdentifiers [ RifEclipseSummaryAddress : : SUMMARY_WELL_LGR ] [ 0 ] - > pdmField ( ) , " WellLgrLgrName " , " Lgr names " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_selectedIdentifiers [ RifEclipseSummaryAddress : : SUMMARY_WELL_LGR ] [ 1 ] - > pdmField ( ) , " WellLgrWellName " , " Wells " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_selectedIdentifiers [ RifEclipseSummaryAddress : : SUMMARY_WELL_LGR ] [ 2 ] - > pdmField ( ) , " WellLgrVectors " , " Vectors " , " " , " " , " " ) ;
2017-09-08 07:49:41 -05:00
2017-09-12 12:51:45 -05:00
CAF_PDM_InitFieldNoDefault ( m_selectedIdentifiers [ RifEclipseSummaryAddress : : SUMMARY_WELL_SEGMENT ] [ 0 ] - > pdmField ( ) , " WellSegmentWellName " , " Wells " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_selectedIdentifiers [ RifEclipseSummaryAddress : : SUMMARY_WELL_SEGMENT ] [ 1 ] - > pdmField ( ) , " WellSegmentNumber " , " Segments " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_selectedIdentifiers [ RifEclipseSummaryAddress : : SUMMARY_WELL_SEGMENT ] [ 2 ] - > pdmField ( ) , " WellSegmentVectors " , " Vectors " , " " , " " , " " ) ;
2017-09-08 07:49:41 -05:00
2017-09-12 12:51:45 -05:00
CAF_PDM_InitFieldNoDefault ( m_selectedIdentifiers [ RifEclipseSummaryAddress : : SUMMARY_BLOCK ] [ 0 ] - > pdmField ( ) , " BlockIjk " , " Cell IJK " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_selectedIdentifiers [ RifEclipseSummaryAddress : : SUMMARY_BLOCK ] [ 1 ] - > pdmField ( ) , " BlockVectors " , " Block vectors " , " " , " " , " " ) ;
2017-09-08 07:49:41 -05:00
2017-09-12 12:51:45 -05:00
CAF_PDM_InitFieldNoDefault ( m_selectedIdentifiers [ RifEclipseSummaryAddress : : SUMMARY_BLOCK_LGR ] [ 0 ] - > pdmField ( ) , " BlockLgrLgrName " , " Lgr names " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_selectedIdentifiers [ RifEclipseSummaryAddress : : SUMMARY_BLOCK_LGR ] [ 1 ] - > pdmField ( ) , " BlockLgrIjk " , " Cell IJK " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_selectedIdentifiers [ RifEclipseSummaryAddress : : SUMMARY_BLOCK_LGR ] [ 2 ] - > pdmField ( ) , " BlockLgrVectors " , " Block vectors " , " " , " " , " " ) ;
2017-09-12 04:58:49 -05:00
CAF_PDM_InitFieldNoDefault ( & m_selectedCurves , " Curves " , " Curves " , " " , " " , " " ) ;
2017-09-08 07:49:41 -05:00
2017-09-12 12:51:45 -05:00
for ( const auto & itemTypes : m_selectedIdentifiers )
2017-09-12 04:58:49 -05:00
{
2017-09-12 12:51:45 -05:00
for ( const auto & itemInputType : itemTypes . second )
2017-09-12 04:58:49 -05:00
{
itemInputType - > pdmField ( ) - > uiCapability ( ) - > setUiEditorTypeName ( caf : : PdmUiTreeSelectionEditor : : uiEditorTypeName ( ) ) ;
}
}
2017-09-08 07:49:41 -05:00
m_selectedCases . uiCapability ( ) - > setUiLabelPosition ( caf : : PdmUiItemInfo : : HIDDEN ) ;
2017-09-12 04:58:49 -05:00
m_selectedCases . uiCapability ( ) - > setUiEditorTypeName ( caf : : PdmUiTreeSelectionEditor : : uiEditorTypeName ( ) ) ;
2017-09-08 07:49:41 -05:00
m_selectedCases . uiCapability ( ) - > setUiLabelPosition ( caf : : PdmUiItemInfo : : HIDDEN ) ;
2017-09-12 12:51:45 -05:00
m_selectedSummaryCategory . uiCapability ( ) - > setUiEditorTypeName ( caf : : PdmUiListEditor : : uiEditorTypeName ( ) ) ;
m_selectedSummaryCategory . uiCapability ( ) - > setUiLabelPosition ( caf : : PdmUiItemInfo : : HIDDEN ) ;
2017-09-12 04:58:49 -05:00
m_selectedCurves . uiCapability ( ) - > setUiLabelPosition ( caf : : PdmUiItemInfo : : HIDDEN ) ;
m_selectedCurves . uiCapability ( ) - > setUiEditorTypeName ( caf : : PdmUiTreeSelectionEditor : : uiEditorTypeName ( ) ) ;
2017-09-08 07:49:41 -05:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicSummaryCurveCreator : : ~ RicSummaryCurveCreator ( )
{
2017-09-12 12:51:45 -05:00
for ( const auto & itemTypes : m_selectedIdentifiers )
2017-09-08 07:49:41 -05:00
{
2017-09-12 12:51:45 -05:00
for ( const auto & itemTypeInput : itemTypes . second )
2017-09-08 07:49:41 -05:00
{
delete itemTypeInput - > pdmField ( ) ;
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveCreator : : fieldChangedByUi ( const caf : : PdmFieldHandle * changedField , const QVariant & oldValue , const QVariant & newValue )
{
2017-09-12 12:51:45 -05:00
if ( changedField = = & m_selectedCurves )
{
loadDataAndUpdatePlot ( ) ;
}
2017-09-08 07:49:41 -05:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList < caf : : PdmOptionItemInfo > RicSummaryCurveCreator : : calculateValueOptions ( const caf : : PdmFieldHandle * fieldNeedingOptions , bool * useOptionsOnly )
{
QList < caf : : PdmOptionItemInfo > options ;
if ( fieldNeedingOptions = = & m_selectedCases )
{
RimProject * proj = RiaApplication : : instance ( ) - > project ( ) ;
std : : vector < RimSummaryCase * > cases ;
proj - > allSummaryCases ( cases ) ;
for ( RimSummaryCase * rimCase : cases )
{
options . push_back ( caf : : PdmOptionItemInfo ( rimCase - > caseName ( ) , rimCase ) ) ;
}
}
else
{
2017-09-12 04:58:49 -05:00
// Lookup item type input field
2017-09-12 12:51:45 -05:00
auto identifierAndField = findIdentifierAndField ( fieldNeedingOptions ) ;
if ( identifierAndField ! = nullptr )
2017-09-08 07:49:41 -05:00
{
2017-09-12 12:51:45 -05:00
auto pdmField = identifierAndField - > pdmField ( ) ;
std : : set < RifEclipseSummaryAddress > addrUnion =
findPossibleSummaryAddresses ( identifierAndField ) ;
std : : set < QString > itemNames ;
2017-09-08 07:49:41 -05:00
for ( const auto & address : addrUnion )
{
2017-09-12 12:51:45 -05:00
auto name = getIdentifierTextFromAddress ( identifierAndField - > summaryIdentifier ( ) , address ) ;
2017-09-08 07:49:41 -05:00
if ( ! name . isEmpty ( ) )
2017-09-12 12:51:45 -05:00
itemNames . insert ( name ) ;
2017-09-08 07:49:41 -05:00
}
2017-09-12 12:51:45 -05:00
for ( const auto & iName : itemNames )
2017-09-08 07:49:41 -05:00
options . push_back ( caf : : PdmOptionItemInfo ( iName , iName ) ) ;
}
}
return options ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveCreator : : defineUiOrdering ( QString uiConfigName , caf : : PdmUiOrdering & uiOrdering )
{
caf : : PdmUiGroup * sourcesGroup = uiOrdering . addNewGroup ( " Sources " ) ;
sourcesGroup - > add ( & m_selectedCases ) ;
caf : : PdmUiGroup * itemTypesGroup = uiOrdering . addNewGroup ( " Items Types " ) ;
2017-09-12 12:51:45 -05:00
itemTypesGroup - > add ( & m_selectedSummaryCategory ) ;
2017-09-08 07:49:41 -05:00
// Dynamic item input editors
2017-09-12 12:51:45 -05:00
auto pdmFields = m_selectedIdentifiers [ m_selectedSummaryCategory ( ) ] ;
2017-09-08 07:49:41 -05:00
if ( pdmFields . size ( ) > 0 )
{
2017-09-12 12:51:45 -05:00
auto groupLabel = QString ( " %1 input " ) . arg ( m_selectedSummaryCategory ( ) . uiText ( ) ) ;
2017-09-08 07:49:41 -05:00
caf : : PdmUiGroup * itemInputGroup = uiOrdering . addNewGroup ( groupLabel ) ;
2017-09-12 12:51:45 -05:00
for ( const auto & pdmField : pdmFields )
2017-09-08 07:49:41 -05:00
itemInputGroup - > add ( pdmField - > pdmField ( ) ) ;
}
2017-09-12 04:58:49 -05:00
caf : : PdmUiGroup * curvesGroup = uiOrdering . addNewGroup ( " Curves " ) ;
curvesGroup - > add ( & m_selectedCurves ) ;
2017-09-08 07:49:41 -05:00
uiOrdering . skipRemainingFields ( true ) ;
}
//--------------------------------------------------------------------------------------------------
/// Returns the summary addresses that match the selected item type and input selections made in GUI
//--------------------------------------------------------------------------------------------------
2017-09-12 12:51:45 -05:00
std : : set < RifEclipseSummaryAddress > RicSummaryCurveCreator : : findPossibleSummaryAddresses ( const SummaryIdentifierAndField * identifierAndField )
2017-09-08 07:49:41 -05:00
{
std : : set < RifEclipseSummaryAddress > addrUnion ;
2017-09-12 12:51:45 -05:00
auto isVectorField = identifierAndField - > summaryIdentifier ( ) = = INPUT_VECTOR_NAME ;
//auto applySelection = identifierAndField == NULL || identifierAndField->summaryIdentifier() == INPUT_VECTOR_NAME;
auto controllingIdentifierAndField = lookupControllingField ( identifierAndField ) ;
if ( ! isVectorField & & controllingIdentifierAndField ! = nullptr & & controllingIdentifierAndField - > pdmField ( ) - > v ( ) . size ( ) = = 0 )
2017-09-12 04:58:49 -05:00
return addrUnion ;
2017-09-08 07:49:41 -05:00
for ( RimSummaryCase * currCase : m_selectedCases )
{
RifReaderEclipseSummary * reader = nullptr ;
if ( currCase & & currCase - > caseData ( ) ) reader = currCase - > caseData ( ) - > summaryReader ( ) ;
if ( reader )
{
2017-09-12 12:51:45 -05:00
const std : : vector < RifEclipseSummaryAddress > & allAddresses = reader - > allResultAddresses ( ) ;
2017-09-08 07:49:41 -05:00
int addressCount = static_cast < int > ( allAddresses . size ( ) ) ;
2017-09-12 12:51:45 -05:00
std : : vector < RicSummaryCurveCreator : : SummaryIdentifierAndField * > selections ;
if ( ! isVectorField & & controllingIdentifierAndField ! = nullptr )
2017-09-12 04:58:49 -05:00
{
// Build selections vector
2017-09-12 12:51:45 -05:00
selections = buildControllingFieldList ( identifierAndField ) ;
2017-09-12 04:58:49 -05:00
}
2017-09-08 07:49:41 -05:00
for ( int i = 0 ; i < addressCount ; i + + )
{
2017-09-12 12:51:45 -05:00
if ( allAddresses [ i ] . category ( ) = = m_selectedSummaryCategory ( ) )
2017-09-12 04:58:49 -05:00
{
2017-09-12 12:51:45 -05:00
bool addressSelected = isVectorField | | controllingIdentifierAndField ! = nullptr ?
isAddressSelected ( allAddresses [ i ] , selections ) : true ;
2017-09-08 07:49:41 -05:00
2017-09-12 04:58:49 -05:00
// Todo: Add text filter
//if (!m_summaryFilter->isIncludedByFilter(allAddresses[i])) continue;
2017-09-08 07:49:41 -05:00
2017-09-12 04:58:49 -05:00
if ( addressSelected )
addrUnion . insert ( allAddresses [ i ] ) ;
}
2017-09-08 07:49:41 -05:00
}
}
}
return addrUnion ;
}
2017-09-12 04:58:49 -05:00
//--------------------------------------------------------------------------------------------------
/// Build a list of relevant selections
//--------------------------------------------------------------------------------------------------
2017-09-12 12:51:45 -05:00
std : : vector < RicSummaryCurveCreator : : SummaryIdentifierAndField * > RicSummaryCurveCreator : : buildControllingFieldList ( const SummaryIdentifierAndField * identifierAndField )
2017-09-12 04:58:49 -05:00
{
2017-09-12 12:51:45 -05:00
std : : vector < RicSummaryCurveCreator : : SummaryIdentifierAndField * > selections ;
auto identifierAndFieldList = m_selectedIdentifiers [ m_selectedSummaryCategory ( ) ] ;
for ( const auto & identifierAndFieldItem : identifierAndFieldList )
2017-09-12 04:58:49 -05:00
{
2017-09-12 12:51:45 -05:00
if ( identifierAndFieldItem = = identifierAndField )
2017-09-12 04:58:49 -05:00
break ;
2017-09-12 12:51:45 -05:00
selections . push_back ( identifierAndFieldItem ) ;
2017-09-12 04:58:49 -05:00
}
return selections ;
}
2017-09-08 07:49:41 -05:00
//--------------------------------------------------------------------------------------------------
/// Returns the stringified value for the specified value in the specfied address object
//--------------------------------------------------------------------------------------------------
2017-09-12 12:51:45 -05:00
QString RicSummaryCurveCreator : : getIdentifierTextFromAddress ( SummaryIdentifierType itemTypeInput , const RifEclipseSummaryAddress & address )
2017-09-08 07:49:41 -05:00
{
switch ( itemTypeInput )
{
case INPUT_REGION_NUMBER : return QString ( " %1 " ) . arg ( address . regionNumber ( ) ) ;
case INPUT_REGION2_NUMBER : return QString ( " %1 " ) . arg ( address . regionNumber2 ( ) ) ;
case INPUT_WELL_NAME : return QString : : fromStdString ( address . wellName ( ) ) ;
case INPUT_WELL_GROUP_NAME : return QString : : fromStdString ( address . wellGroupName ( ) ) ;
case INPUT_CELL_IJK : return QString ( " %1,%2,%3 " ) . arg ( QString : : number ( address . cellI ( ) ) ,
QString : : number ( address . cellJ ( ) ) , QString : : number ( address . cellK ( ) ) ) ;
case INPUT_LGR_NAME : return QString : : fromStdString ( address . lgrName ( ) ) ;
case INPUT_SEGMENT_NUMBER : return QString ( " %1 " ) . arg ( address . wellSegmentNumber ( ) ) ;
2017-09-12 04:58:49 -05:00
case INPUT_VECTOR_NAME : return QString : : fromStdString ( address . quantityName ( ) ) ;
2017-09-08 07:49:41 -05:00
}
return " " ;
}
//--------------------------------------------------------------------------------------------------
2017-09-12 04:58:49 -05:00
/// Returns pdm field info from the specified pdm field
2017-09-08 07:49:41 -05:00
//--------------------------------------------------------------------------------------------------
2017-09-12 12:51:45 -05:00
RicSummaryCurveCreator : : SummaryIdentifierAndField * RicSummaryCurveCreator : : findIdentifierAndField ( const caf : : PdmFieldHandle * pdmFieldHandle )
2017-09-08 07:49:41 -05:00
{
2017-09-12 12:51:45 -05:00
for ( const auto & itemTypes : m_selectedIdentifiers )
2017-09-08 07:49:41 -05:00
{
2017-09-12 12:51:45 -05:00
for ( const auto & itemTypeInput : itemTypes . second )
2017-09-08 07:49:41 -05:00
{
if ( pdmFieldHandle = = itemTypeInput - > pdmField ( ) )
return itemTypeInput ;
}
}
return nullptr ;
}
//--------------------------------------------------------------------------------------------------
/// Returns the parent pdm field info for the specified pdm field info.
/// If the specified pdm field info is the topmost (i.e. index is 0), null pointer is returned
//--------------------------------------------------------------------------------------------------
2017-09-12 12:51:45 -05:00
RicSummaryCurveCreator : : SummaryIdentifierAndField * RicSummaryCurveCreator : : lookupControllingField ( const RicSummaryCurveCreator : : SummaryIdentifierAndField * identifierAndField )
2017-09-08 07:49:41 -05:00
{
2017-09-12 12:51:45 -05:00
for ( const auto & identifierAndFieldList : m_selectedIdentifiers )
2017-09-08 07:49:41 -05:00
{
2017-09-12 12:51:45 -05:00
int index = 0 ;
for ( const auto & iaf : identifierAndFieldList . second )
2017-09-08 07:49:41 -05:00
{
2017-09-12 12:51:45 -05:00
if ( iaf = = identifierAndField )
2017-09-08 07:49:41 -05:00
{
2017-09-12 12:51:45 -05:00
return index > 0 ? identifierAndFieldList . second [ index - 1 ] : nullptr ;
2017-09-08 07:49:41 -05:00
}
2017-09-12 12:51:45 -05:00
index + + ;
2017-09-08 07:49:41 -05:00
}
}
return nullptr ;
}
//--------------------------------------------------------------------------------------------------
2017-09-12 04:58:49 -05:00
/// Returns true if the specified address object matches the selections
2017-09-08 07:49:41 -05:00
//--------------------------------------------------------------------------------------------------
2017-09-12 12:51:45 -05:00
bool RicSummaryCurveCreator : : isAddressSelected ( const RifEclipseSummaryAddress & address , const std : : vector < SummaryIdentifierAndField * > & identifierAndFieldList )
2017-09-08 07:49:41 -05:00
{
2017-09-12 12:51:45 -05:00
for ( const auto & identifierAndField : identifierAndFieldList )
2017-09-08 07:49:41 -05:00
{
2017-09-12 04:58:49 -05:00
bool match = false ;
2017-09-12 12:51:45 -05:00
for ( const auto & selection : identifierAndField - > pdmField ( ) - > v ( ) )
2017-09-08 07:49:41 -05:00
{
2017-09-12 12:51:45 -05:00
if ( QString : : compare ( getIdentifierTextFromAddress ( identifierAndField - > summaryIdentifier ( ) , address ) , selection ) = = 0 )
2017-09-12 04:58:49 -05:00
{
match = true ;
break ;
}
2017-09-08 07:49:41 -05:00
}
2017-09-12 04:58:49 -05:00
if ( ! match )
return false ;
2017-09-08 07:49:41 -05:00
}
2017-09-12 04:58:49 -05:00
return true ;
2017-09-08 07:49:41 -05:00
}
2017-09-12 12:51:45 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveCreator : : loadDataAndUpdatePlot ( )
{
//syncCurvesFromUiSelection();
//loadDataAndUpdate();
RimSummaryPlot * plot = nullptr ;
firstAncestorOrThisOfType ( plot ) ;
plot - > updateAxes ( ) ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveCreator : : syncCurvesFromUiSelection ( )
{
// Create a search map containing whats supposed to be curves
std : : set < std : : pair < RimSummaryCase * , RifEclipseSummaryAddress > > newCurveDefinitions ;
// Populate the newCurveDefinitions from the Gui
std : : set < RifEclipseSummaryAddress > addrUnion = findPossibleSummaryAddresses ( nullptr ) ;
for ( RimSummaryCase * currentCase : m_selectedCases )
{
if ( ! currentCase | | ! currentCase - > caseData ( ) | | ! currentCase - > caseData ( ) - > summaryReader ( ) ) continue ;
RifReaderEclipseSummary * reader = currentCase - > caseData ( ) - > summaryReader ( ) ;
//for (const RifEclipseSummaryAddress& addr : m_uiFilterResultMultiSelection.v())
//{
// if (!reader->hasAddress(addr)) continue;
// if (addrUnion.count(addr) == 0) continue; // Wash the possible "old" ui selection with new filter
// newCurveDefinitions.insert(std::make_pair(currentCase, addr));
//}
}
// m_curves.deleteAllChildObjects();
// createCurvesFromCurveDefinitions(newCurveDefinitions);
}