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-13 09:31:52 -05:00
# include <stack>
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-13 11:55:58 -05:00
RicSummaryCurveCreator : : RicSummaryCurveCreator ( ) : m_identifierFieldsMap (
2017-09-08 07:49:41 -05:00
{
2017-09-12 12:51:45 -05:00
{ RifEclipseSummaryAddress : : SUMMARY_FIELD , {
2017-09-13 09:31:52 -05:00
{ new SummaryIdentifierAndField ( RifEclipseSummaryAddress : : INPUT_VECTOR_NAME ) }
2017-09-12 04:58:49 -05:00
} } ,
2017-09-12 12:51:45 -05:00
{ RifEclipseSummaryAddress : : SUMMARY_AQUIFER , {
2017-09-13 09:31:52 -05:00
{ new SummaryIdentifierAndField ( RifEclipseSummaryAddress : : INPUT_VECTOR_NAME ) }
2017-09-12 04:58:49 -05:00
} } ,
2017-09-12 12:51:45 -05:00
{ RifEclipseSummaryAddress : : SUMMARY_NETWORK , {
2017-09-13 09:31:52 -05:00
{ new SummaryIdentifierAndField ( RifEclipseSummaryAddress : : INPUT_VECTOR_NAME ) }
2017-09-12 04:58:49 -05:00
} } ,
2017-09-12 12:51:45 -05:00
{ RifEclipseSummaryAddress : : SUMMARY_MISC , {
2017-09-13 09:31:52 -05:00
{ new SummaryIdentifierAndField ( RifEclipseSummaryAddress : : INPUT_VECTOR_NAME ) }
2017-09-12 04:58:49 -05:00
} } ,
2017-09-12 12:51:45 -05:00
{ RifEclipseSummaryAddress : : SUMMARY_REGION , {
2017-09-13 09:31:52 -05:00
{ new SummaryIdentifierAndField ( RifEclipseSummaryAddress : : INPUT_REGION_NUMBER ) } ,
{ new SummaryIdentifierAndField ( RifEclipseSummaryAddress : : INPUT_VECTOR_NAME ) }
2017-09-08 07:49:41 -05:00
} } ,
2017-09-12 12:51:45 -05:00
{ RifEclipseSummaryAddress : : SUMMARY_REGION_2_REGION , {
2017-09-13 09:31:52 -05:00
{ new SummaryIdentifierAndField ( RifEclipseSummaryAddress : : INPUT_REGION_NUMBER ) } ,
{ new SummaryIdentifierAndField ( RifEclipseSummaryAddress : : INPUT_REGION2_NUMBER ) } ,
{ new SummaryIdentifierAndField ( RifEclipseSummaryAddress : : INPUT_VECTOR_NAME ) }
2017-09-08 07:49:41 -05:00
} } ,
2017-09-12 12:51:45 -05:00
{ RifEclipseSummaryAddress : : SUMMARY_WELL_GROUP , {
2017-09-13 09:31:52 -05:00
{ new SummaryIdentifierAndField ( RifEclipseSummaryAddress : : INPUT_WELL_GROUP_NAME ) } ,
{ new SummaryIdentifierAndField ( RifEclipseSummaryAddress : : INPUT_VECTOR_NAME ) }
2017-09-08 07:49:41 -05:00
} } ,
2017-09-12 12:51:45 -05:00
{ RifEclipseSummaryAddress : : SUMMARY_WELL , {
2017-09-13 09:31:52 -05:00
{ new SummaryIdentifierAndField ( RifEclipseSummaryAddress : : INPUT_WELL_NAME ) } ,
{ new SummaryIdentifierAndField ( RifEclipseSummaryAddress : : INPUT_VECTOR_NAME ) }
2017-09-08 07:49:41 -05:00
} } ,
2017-09-12 12:51:45 -05:00
{ RifEclipseSummaryAddress : : SUMMARY_WELL_COMPLETION , {
2017-09-13 09:31:52 -05:00
{ new SummaryIdentifierAndField ( RifEclipseSummaryAddress : : INPUT_WELL_NAME ) } ,
{ new SummaryIdentifierAndField ( RifEclipseSummaryAddress : : INPUT_CELL_IJK ) } ,
{ new SummaryIdentifierAndField ( RifEclipseSummaryAddress : : INPUT_VECTOR_NAME ) }
2017-09-08 07:49:41 -05:00
} } ,
2017-09-12 12:51:45 -05:00
{ RifEclipseSummaryAddress : : SUMMARY_WELL_COMPLETION_LGR , {
2017-09-13 09:31:52 -05:00
{ new SummaryIdentifierAndField ( RifEclipseSummaryAddress : : INPUT_LGR_NAME ) } ,
{ new SummaryIdentifierAndField ( RifEclipseSummaryAddress : : INPUT_WELL_NAME ) } ,
{ new SummaryIdentifierAndField ( RifEclipseSummaryAddress : : INPUT_CELL_IJK ) } ,
{ new SummaryIdentifierAndField ( RifEclipseSummaryAddress : : INPUT_VECTOR_NAME ) }
2017-09-08 07:49:41 -05:00
} } ,
2017-09-12 12:51:45 -05:00
{ RifEclipseSummaryAddress : : SUMMARY_WELL_LGR , {
2017-09-13 09:31:52 -05:00
{ new SummaryIdentifierAndField ( RifEclipseSummaryAddress : : INPUT_LGR_NAME ) } ,
{ new SummaryIdentifierAndField ( RifEclipseSummaryAddress : : INPUT_WELL_NAME ) } ,
{ new SummaryIdentifierAndField ( RifEclipseSummaryAddress : : INPUT_VECTOR_NAME ) }
2017-09-08 07:49:41 -05:00
} } ,
2017-09-12 12:51:45 -05:00
{ RifEclipseSummaryAddress : : SUMMARY_WELL_SEGMENT , {
2017-09-13 09:31:52 -05:00
{ new SummaryIdentifierAndField ( RifEclipseSummaryAddress : : INPUT_WELL_NAME ) } ,
{ new SummaryIdentifierAndField ( RifEclipseSummaryAddress : : INPUT_SEGMENT_NUMBER ) } ,
{ new SummaryIdentifierAndField ( RifEclipseSummaryAddress : : INPUT_VECTOR_NAME ) }
2017-09-08 07:49:41 -05:00
} } ,
2017-09-12 12:51:45 -05:00
{ RifEclipseSummaryAddress : : SUMMARY_BLOCK , {
2017-09-13 09:31:52 -05:00
{ new SummaryIdentifierAndField ( RifEclipseSummaryAddress : : INPUT_CELL_IJK ) } ,
{ new SummaryIdentifierAndField ( RifEclipseSummaryAddress : : INPUT_VECTOR_NAME ) }
2017-09-08 07:49:41 -05:00
} } ,
2017-09-12 12:51:45 -05:00
{ RifEclipseSummaryAddress : : SUMMARY_BLOCK_LGR , {
2017-09-13 09:31:52 -05:00
{ new SummaryIdentifierAndField ( RifEclipseSummaryAddress : : INPUT_LGR_NAME ) } ,
{ new SummaryIdentifierAndField ( RifEclipseSummaryAddress : : INPUT_CELL_IJK ) } ,
{ new SummaryIdentifierAndField ( RifEclipseSummaryAddress : : 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-13 11:55:58 -05:00
CAF_PDM_InitFieldNoDefault ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_FIELD ] [ 0 ] - > pdmField ( ) , " FieldVectors " , " Field vectors " , " " , " " , " " ) ;
2017-09-12 04:58:49 -05:00
2017-09-13 11:55:58 -05:00
CAF_PDM_InitFieldNoDefault ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_AQUIFER ] [ 0 ] - > pdmField ( ) , " AquiferVectors " , " Aquifer Vectors " , " " , " " , " " ) ;
2017-09-12 04:58:49 -05:00
2017-09-13 11:55:58 -05:00
CAF_PDM_InitFieldNoDefault ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_NETWORK ] [ 0 ] - > pdmField ( ) , " NetworkVectors " , " Network Vectors " , " " , " " , " " ) ;
2017-09-12 04:58:49 -05:00
2017-09-13 11:55:58 -05:00
CAF_PDM_InitFieldNoDefault ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_MISC ] [ 0 ] - > pdmField ( ) , " MiscVectors " , " Misc Vectors " , " " , " " , " " ) ;
2017-09-08 07:49:41 -05:00
2017-09-13 11:55:58 -05:00
CAF_PDM_InitFieldNoDefault ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_REGION ] [ 0 ] - > pdmField ( ) , " Regions " , " Regions " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_REGION ] [ 1 ] - > pdmField ( ) , " RegionsVectors " , " Regions Vectors " , " " , " " , " " ) ;
2017-09-08 07:49:41 -05:00
2017-09-13 11:55:58 -05:00
CAF_PDM_InitFieldNoDefault ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_REGION_2_REGION ] [ 0 ] - > pdmField ( ) , " Region2RegionRegions " , " Regions " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_REGION_2_REGION ] [ 1 ] - > pdmField ( ) , " Region2RegionRegion2s " , " Region2s " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_REGION_2_REGION ] [ 2 ] - > pdmField ( ) , " Region2RegionVectors " , " Region2s Vectors " , " " , " " , " " ) ;
2017-09-08 07:49:41 -05:00
2017-09-13 11:55:58 -05:00
CAF_PDM_InitFieldNoDefault ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL_GROUP ] [ 0 ] - > pdmField ( ) , " WellGroupWellGroupNames " , " Well groups " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL_GROUP ] [ 1 ] - > pdmField ( ) , " WellGroupVectors " , " Well Group Vectors " , " " , " " , " " ) ;
2017-09-08 07:49:41 -05:00
2017-09-13 11:55:58 -05:00
CAF_PDM_InitFieldNoDefault ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL ] [ 0 ] - > pdmField ( ) , " WellWellName " , " Wells " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL ] [ 1 ] - > pdmField ( ) , " WellVectors " , " Well Vectors " , " " , " " , " " ) ;
2017-09-08 07:49:41 -05:00
2017-09-13 11:55:58 -05:00
CAF_PDM_InitFieldNoDefault ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL_COMPLETION ] [ 0 ] - > pdmField ( ) , " WellCompletionWellName " , " Wells " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL_COMPLETION ] [ 1 ] - > pdmField ( ) , " WellCompletionIjk " , " Cell IJK " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL_COMPLETION ] [ 2 ] - > pdmField ( ) , " WellCompletionVectors " , " Well Completion Vectors " , " " , " " , " " ) ;
2017-09-08 07:49:41 -05:00
2017-09-13 11:55:58 -05:00
CAF_PDM_InitFieldNoDefault ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL_COMPLETION_LGR ] [ 0 ] - > pdmField ( ) , " WellCompletionLgrLgrName " , " LGR Names " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL_COMPLETION_LGR ] [ 1 ] - > pdmField ( ) , " WellCompletionLgrWellName " , " Wells " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL_COMPLETION_LGR ] [ 2 ] - > pdmField ( ) , " WellCompletionLgrIjk " , " Cell IJK " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL_COMPLETION_LGR ] [ 3 ] - > pdmField ( ) , " WellCompletionLgrVectors " , " Well Completion Vectors " , " " , " " , " " ) ;
2017-09-08 07:49:41 -05:00
2017-09-13 11:55:58 -05:00
CAF_PDM_InitFieldNoDefault ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL_LGR ] [ 0 ] - > pdmField ( ) , " WellLgrLgrName " , " LGR Names " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL_LGR ] [ 1 ] - > pdmField ( ) , " WellLgrWellName " , " Wells " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL_LGR ] [ 2 ] - > pdmField ( ) , " WellLgrVectors " , " Vectors " , " " , " " , " " ) ;
2017-09-08 07:49:41 -05:00
2017-09-13 11:55:58 -05:00
CAF_PDM_InitFieldNoDefault ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL_SEGMENT ] [ 0 ] - > pdmField ( ) , " WellSegmentWellName " , " Wells " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL_SEGMENT ] [ 1 ] - > pdmField ( ) , " WellSegmentNumber " , " Segments " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL_SEGMENT ] [ 2 ] - > pdmField ( ) , " WellSegmentVectors " , " Vectors " , " " , " " , " " ) ;
2017-09-08 07:49:41 -05:00
2017-09-13 11:55:58 -05:00
CAF_PDM_InitFieldNoDefault ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_BLOCK ] [ 0 ] - > pdmField ( ) , " BlockIjk " , " Cell IJK " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_BLOCK ] [ 1 ] - > pdmField ( ) , " BlockVectors " , " Block Vectors " , " " , " " , " " ) ;
2017-09-08 07:49:41 -05:00
2017-09-13 11:55:58 -05:00
CAF_PDM_InitFieldNoDefault ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_BLOCK_LGR ] [ 0 ] - > pdmField ( ) , " BlockLgrLgrName " , " LGR Names " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_BLOCK_LGR ] [ 1 ] - > pdmField ( ) , " BlockLgrIjk " , " Cell IJK " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_BLOCK_LGR ] [ 2 ] - > pdmField ( ) , " BlockLgrVectors " , " Block Vectors " , " " , " " , " " ) ;
2017-09-12 04:58:49 -05:00
2017-09-13 10:18:15 -05:00
CAF_PDM_InitFieldNoDefault ( & m_previewPlot , " PreviewPlot " , " PreviewPlot " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( & m_selectedCurveTexts , " CurveTexts " , " Selected Curves " , " " , " " , " " ) ;
m_selectedCurveTexts . uiCapability ( ) - > setUiLabelPosition ( caf : : PdmUiItemInfo : : HIDDEN ) ;
2017-09-13 09:31:52 -05:00
m_previewPlot = new RimSummaryPlot ( ) ;
2017-09-08 07:49:41 -05:00
2017-09-13 11:55:58 -05:00
for ( const auto & itemTypes : m_identifierFieldsMap )
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-13 06:55:28 -05:00
itemInputType - > pdmField ( ) - > uiCapability ( ) - > setUiLabelPosition ( caf : : PdmUiItemInfo : : TOP ) ;
2017-09-12 04:58:49 -05:00
}
2017-09-13 09:38:54 -05:00
itemTypes . second . back ( ) - > pdmField ( ) - > uiCapability ( ) - > setUiLabelPosition ( caf : : PdmUiItemInfo : : HIDDEN ) ;
2017-09-12 04:58:49 -05:00
}
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-13 09:38:54 -05:00
2017-09-12 12:51:45 -05:00
m_selectedSummaryCategory . uiCapability ( ) - > setUiEditorTypeName ( caf : : PdmUiListEditor : : uiEditorTypeName ( ) ) ;
m_selectedSummaryCategory . uiCapability ( ) - > setUiLabelPosition ( caf : : PdmUiItemInfo : : HIDDEN ) ;
2017-09-13 09:38:54 -05:00
2017-09-13 09:31:52 -05:00
m_previewPlot . uiCapability ( ) - > setUiLabelPosition ( caf : : PdmUiItemInfo : : HIDDEN ) ;
//m_previewPlot.uiCapability()->setUiEditorTypeName(caf::PdmUiTreeSelectionEditor::uiEditorTypeName());
2017-09-08 07:49:41 -05:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicSummaryCurveCreator : : ~ RicSummaryCurveCreator ( )
{
2017-09-13 11:55:58 -05:00
for ( const auto & itemTypes : m_identifierFieldsMap )
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-13 09:31:52 -05:00
// Lookup item type input field
auto identifierAndField = findIdentifierAndField ( changedField ) ;
if ( identifierAndField ! = nullptr & & identifierAndField - > summaryIdentifier ( ) = = RifEclipseSummaryAddress : : INPUT_VECTOR_NAME )
{
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 ) ) ;
}
2017-09-13 09:31:52 -05:00
}
else if ( fieldNeedingOptions = = & m_previewPlot )
{
2017-09-08 07:49:41 -05:00
}
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 ) ;
2017-09-13 09:38:54 -05:00
caf : : PdmUiGroup * itemTypesGroup = uiOrdering . addNewGroup ( " Identifier Types " ) ;
2017-09-12 12:51:45 -05:00
itemTypesGroup - > add ( & m_selectedSummaryCategory ) ;
2017-09-08 07:49:41 -05:00
2017-09-13 08:22:16 -05:00
RifEclipseSummaryAddress : : SummaryVarCategory sumCategory = m_selectedSummaryCategory ( ) ;
if ( sumCategory = = RifEclipseSummaryAddress : : SUMMARY_FIELD )
{
{
caf : : PdmUiGroup * myGroup = uiOrdering . addNewGroup ( " Blank " ) ;
}
{
2017-09-13 09:38:54 -05:00
caf : : PdmUiGroup * myGroup = uiOrdering . addNewGroup ( " Properties " ) ;
2017-09-13 11:55:58 -05:00
myGroup - > add ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_FIELD ] [ 0 ] - > pdmField ( ) ) ;
2017-09-13 08:22:16 -05:00
}
}
else if ( sumCategory = = RifEclipseSummaryAddress : : SUMMARY_AQUIFER )
{
{
caf : : PdmUiGroup * myGroup = uiOrdering . addNewGroup ( " Blank " ) ;
}
{
2017-09-13 09:38:54 -05:00
caf : : PdmUiGroup * myGroup = uiOrdering . addNewGroup ( " Properties " ) ;
2017-09-13 11:55:58 -05:00
myGroup - > add ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_AQUIFER ] [ 0 ] - > pdmField ( ) ) ;
2017-09-13 08:22:16 -05:00
}
}
else if ( sumCategory = = RifEclipseSummaryAddress : : SUMMARY_NETWORK )
{
{
caf : : PdmUiGroup * myGroup = uiOrdering . addNewGroup ( " Blank " ) ;
}
{
2017-09-13 09:38:54 -05:00
caf : : PdmUiGroup * myGroup = uiOrdering . addNewGroup ( " Properties " ) ;
2017-09-13 11:55:58 -05:00
myGroup - > add ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_NETWORK ] [ 0 ] - > pdmField ( ) ) ;
2017-09-13 08:22:16 -05:00
}
}
else if ( sumCategory = = RifEclipseSummaryAddress : : SUMMARY_MISC )
{
{
caf : : PdmUiGroup * myGroup = uiOrdering . addNewGroup ( " Blank " ) ;
}
{
2017-09-13 09:38:54 -05:00
caf : : PdmUiGroup * myGroup = uiOrdering . addNewGroup ( " Properties " ) ;
2017-09-13 11:55:58 -05:00
myGroup - > add ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_MISC ] [ 0 ] - > pdmField ( ) ) ;
2017-09-13 08:22:16 -05:00
}
}
else if ( sumCategory = = RifEclipseSummaryAddress : : SUMMARY_REGION )
{
{
caf : : PdmUiGroup * myGroup = uiOrdering . addNewGroup ( " Regions " ) ;
2017-09-13 11:55:58 -05:00
myGroup - > add ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_REGION ] [ 0 ] - > pdmField ( ) ) ;
2017-09-13 08:22:16 -05:00
}
{
2017-09-13 09:38:54 -05:00
caf : : PdmUiGroup * myGroup = uiOrdering . addNewGroup ( " Properties " ) ;
2017-09-13 11:55:58 -05:00
myGroup - > add ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_REGION ] [ 1 ] - > pdmField ( ) ) ;
2017-09-13 08:22:16 -05:00
}
}
else if ( sumCategory = = RifEclipseSummaryAddress : : SUMMARY_REGION_2_REGION )
{
{
caf : : PdmUiGroup * myGroup = uiOrdering . addNewGroup ( " Regions " ) ;
2017-09-13 11:55:58 -05:00
myGroup - > add ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_REGION_2_REGION ] [ 0 ] - > pdmField ( ) ) ;
myGroup - > add ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_REGION_2_REGION ] [ 1 ] - > pdmField ( ) ) ;
2017-09-13 08:22:16 -05:00
}
{
2017-09-13 09:38:54 -05:00
caf : : PdmUiGroup * myGroup = uiOrdering . addNewGroup ( " Properties " ) ;
2017-09-13 11:55:58 -05:00
myGroup - > add ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_REGION_2_REGION ] [ 2 ] - > pdmField ( ) ) ;
2017-09-13 08:22:16 -05:00
}
}
else if ( sumCategory = = RifEclipseSummaryAddress : : SUMMARY_WELL_GROUP )
{
{
caf : : PdmUiGroup * myGroup = uiOrdering . addNewGroup ( " Well Groups " ) ;
2017-09-13 11:55:58 -05:00
myGroup - > add ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL_GROUP ] [ 0 ] - > pdmField ( ) ) ;
2017-09-13 08:22:16 -05:00
}
{
2017-09-13 09:38:54 -05:00
caf : : PdmUiGroup * myGroup = uiOrdering . addNewGroup ( " Properties " ) ;
2017-09-13 11:55:58 -05:00
myGroup - > add ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL_GROUP ] [ 1 ] - > pdmField ( ) ) ;
2017-09-13 08:22:16 -05:00
}
}
else if ( sumCategory = = RifEclipseSummaryAddress : : SUMMARY_WELL )
{
{
caf : : PdmUiGroup * myGroup = uiOrdering . addNewGroup ( " Wells " ) ;
2017-09-13 11:55:58 -05:00
myGroup - > add ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL ] [ 0 ] - > pdmField ( ) ) ;
2017-09-13 08:22:16 -05:00
}
{
2017-09-13 09:38:54 -05:00
caf : : PdmUiGroup * myGroup = uiOrdering . addNewGroup ( " Properties " ) ;
2017-09-13 11:55:58 -05:00
myGroup - > add ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL ] [ 1 ] - > pdmField ( ) ) ;
2017-09-13 08:22:16 -05:00
}
}
else if ( sumCategory = = RifEclipseSummaryAddress : : SUMMARY_WELL_COMPLETION )
{
{
2017-09-13 09:38:54 -05:00
caf : : PdmUiGroup * myGroup = uiOrdering . addNewGroup ( " Completions " ) ;
2017-09-13 11:55:58 -05:00
myGroup - > add ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL_COMPLETION ] [ 0 ] - > pdmField ( ) ) ;
myGroup - > add ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL_COMPLETION ] [ 1 ] - > pdmField ( ) ) ;
2017-09-13 08:22:16 -05:00
}
{
2017-09-13 09:38:54 -05:00
caf : : PdmUiGroup * myGroup = uiOrdering . addNewGroup ( " Properties " ) ;
2017-09-13 11:55:58 -05:00
myGroup - > add ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL_COMPLETION ] [ 2 ] - > pdmField ( ) ) ;
2017-09-13 08:22:16 -05:00
}
}
else if ( sumCategory = = RifEclipseSummaryAddress : : SUMMARY_WELL_COMPLETION_LGR )
{
{
2017-09-13 09:38:54 -05:00
caf : : PdmUiGroup * myGroup = uiOrdering . addNewGroup ( " LGR Completions " ) ;
2017-09-13 11:55:58 -05:00
myGroup - > add ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL_COMPLETION_LGR ] [ 0 ] - > pdmField ( ) ) ;
myGroup - > add ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL_COMPLETION_LGR ] [ 1 ] - > pdmField ( ) ) ;
myGroup - > add ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL_COMPLETION_LGR ] [ 2 ] - > pdmField ( ) ) ;
2017-09-13 08:22:16 -05:00
}
{
2017-09-13 09:38:54 -05:00
caf : : PdmUiGroup * myGroup = uiOrdering . addNewGroup ( " Properties " ) ;
2017-09-13 11:55:58 -05:00
myGroup - > add ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL_COMPLETION_LGR ] [ 3 ] - > pdmField ( ) ) ;
2017-09-13 08:22:16 -05:00
}
}
else if ( sumCategory = = RifEclipseSummaryAddress : : SUMMARY_WELL_LGR )
{
{
2017-09-13 09:38:54 -05:00
caf : : PdmUiGroup * myGroup = uiOrdering . addNewGroup ( " LGR Wells " ) ;
2017-09-13 11:55:58 -05:00
myGroup - > add ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL_LGR ] [ 0 ] - > pdmField ( ) ) ;
myGroup - > add ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL_LGR ] [ 1 ] - > pdmField ( ) ) ;
2017-09-13 08:22:16 -05:00
}
{
2017-09-13 09:38:54 -05:00
caf : : PdmUiGroup * myGroup = uiOrdering . addNewGroup ( " Properties " ) ;
2017-09-13 11:55:58 -05:00
myGroup - > add ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL_LGR ] [ 2 ] - > pdmField ( ) ) ;
2017-09-13 08:22:16 -05:00
}
}
else if ( sumCategory = = RifEclipseSummaryAddress : : SUMMARY_WELL_SEGMENT )
{
{
2017-09-13 09:38:54 -05:00
caf : : PdmUiGroup * myGroup = uiOrdering . addNewGroup ( " Well Segments " ) ;
2017-09-13 11:55:58 -05:00
myGroup - > add ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL_SEGMENT ] [ 0 ] - > pdmField ( ) ) ;
myGroup - > add ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL_SEGMENT ] [ 1 ] - > pdmField ( ) ) ;
2017-09-13 08:22:16 -05:00
}
{
2017-09-13 09:38:54 -05:00
caf : : PdmUiGroup * myGroup = uiOrdering . addNewGroup ( " Properties " ) ;
2017-09-13 11:55:58 -05:00
myGroup - > add ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_WELL_SEGMENT ] [ 2 ] - > pdmField ( ) ) ;
2017-09-13 08:22:16 -05:00
}
}
else if ( sumCategory = = RifEclipseSummaryAddress : : SUMMARY_BLOCK )
{
{
caf : : PdmUiGroup * myGroup = uiOrdering . addNewGroup ( " Blocks " ) ;
2017-09-13 11:55:58 -05:00
myGroup - > add ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_BLOCK ] [ 0 ] - > pdmField ( ) ) ;
2017-09-13 08:22:16 -05:00
}
{
2017-09-13 09:38:54 -05:00
caf : : PdmUiGroup * myGroup = uiOrdering . addNewGroup ( " Properties " ) ;
2017-09-13 11:55:58 -05:00
myGroup - > add ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_BLOCK ] [ 1 ] - > pdmField ( ) ) ;
2017-09-13 08:22:16 -05:00
}
}
else if ( sumCategory = = RifEclipseSummaryAddress : : SUMMARY_BLOCK_LGR )
{
{
2017-09-13 09:38:54 -05:00
caf : : PdmUiGroup * myGroup = uiOrdering . addNewGroup ( " LGR Blocks " ) ;
2017-09-13 11:55:58 -05:00
myGroup - > add ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_BLOCK_LGR ] [ 0 ] - > pdmField ( ) ) ;
myGroup - > add ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_BLOCK_LGR ] [ 1 ] - > pdmField ( ) ) ;
2017-09-13 08:22:16 -05:00
}
{
2017-09-13 09:38:54 -05:00
caf : : PdmUiGroup * myGroup = uiOrdering . addNewGroup ( " Properties " ) ;
2017-09-13 11:55:58 -05:00
myGroup - > add ( m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_BLOCK_LGR ] [ 2 ] - > pdmField ( ) ) ;
2017-09-13 08:22:16 -05:00
}
}
2017-09-08 07:49:41 -05:00
// Dynamic item input editors
2017-09-13 08:22:16 -05:00
/*
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-13 08:22:16 -05:00
*/
2017-09-08 07:49:41 -05:00
2017-09-13 11:55:58 -05:00
//caf::PdmUiGroup* curvesGroup = uiOrdering.addNewGroup("Curves");
//curvesGroup->add(&m_selectedCurveTexts);
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-13 09:31:52 -05:00
auto isVectorField = identifierAndField ! = nullptr & & identifierAndField - > summaryIdentifier ( ) = = RifEclipseSummaryAddress : : INPUT_VECTOR_NAME ;
2017-09-13 03:14:18 -05:00
auto controllingIdentifierAndField = identifierAndField ! = nullptr ? lookupControllingField ( identifierAndField ) : nullptr ;
2017-09-12 12:51:45 -05:00
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-13 03:14:18 -05:00
bool applySelections = identifierAndField = = nullptr | | ( ! isVectorField & & controllingIdentifierAndField ! = nullptr ) ;
std : : vector < SummaryIdentifierAndField * > selections ;
if ( applySelections )
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-13 03:14:18 -05:00
bool addressSelected = applySelections ? 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 ;
2017-09-13 11:55:58 -05:00
auto identifierAndFieldList = m_identifierFieldsMap [ m_selectedSummaryCategory ( ) ] ;
2017-09-12 12:51:45 -05:00
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-13 09:31:52 -05:00
QString RicSummaryCurveCreator : : getIdentifierTextFromAddress ( RifEclipseSummaryAddress : : SummaryIdentifierType itemTypeInput , const RifEclipseSummaryAddress & address )
2017-09-08 07:49:41 -05:00
{
switch ( itemTypeInput )
{
2017-09-13 09:31:52 -05:00
case RifEclipseSummaryAddress : : INPUT_REGION_NUMBER : return QString ( " %1 " ) . arg ( address . regionNumber ( ) ) ;
case RifEclipseSummaryAddress : : INPUT_REGION2_NUMBER : return QString ( " %1 " ) . arg ( address . regionNumber2 ( ) ) ;
case RifEclipseSummaryAddress : : INPUT_WELL_NAME : return QString : : fromStdString ( address . wellName ( ) ) ;
case RifEclipseSummaryAddress : : INPUT_WELL_GROUP_NAME : return QString : : fromStdString ( address . wellGroupName ( ) ) ;
case RifEclipseSummaryAddress : : INPUT_CELL_IJK : return QString ( " %1,%2,%3 " ) . arg ( QString : : number ( address . cellI ( ) ) ,
2017-09-08 07:49:41 -05:00
QString : : number ( address . cellJ ( ) ) , QString : : number ( address . cellK ( ) ) ) ;
2017-09-13 09:31:52 -05:00
case RifEclipseSummaryAddress : : INPUT_LGR_NAME : return QString : : fromStdString ( address . lgrName ( ) ) ;
case RifEclipseSummaryAddress : : INPUT_SEGMENT_NUMBER : return QString ( " %1 " ) . arg ( address . wellSegmentNumber ( ) ) ;
case RifEclipseSummaryAddress : : 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-13 11:55:58 -05:00
for ( const auto & itemTypes : m_identifierFieldsMap )
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-13 11:55:58 -05:00
for ( const auto & identifierAndFieldList : m_identifierFieldsMap )
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-13 09:31:52 -05:00
std : : set < RifEclipseSummaryAddress > RicSummaryCurveCreator : : buildAddressListFromSelections ( )
{
std : : set < RifEclipseSummaryAddress > addressSet ;
2017-09-13 11:55:58 -05:00
for ( const auto & identifierAndFieldList : m_identifierFieldsMap )
2017-09-13 09:31:52 -05:00
{
std : : vector < std : : pair < RifEclipseSummaryAddress : : SummaryIdentifierType , QString > > selectionStack ;
addSelectionAddress ( identifierAndFieldList . first , identifierAndFieldList . second . begin ( ) , addressSet , selectionStack ) ;
}
return addressSet ;
}
void RicSummaryCurveCreator : : addSelectionAddress ( RifEclipseSummaryAddress : : SummaryVarCategory category ,
std : : vector < SummaryIdentifierAndField * > : : const_iterator & identifierAndFieldItr ,
std : : set < RifEclipseSummaryAddress > & addressSet ,
std : : vector < std : : pair < RifEclipseSummaryAddress : : SummaryIdentifierType , QString > > & identifierPath )
{
for ( const auto & identifierText : ( * identifierAndFieldItr ) - > pdmField ( ) - > v ( ) )
{
identifierPath . push_back ( std : : make_pair ( ( * identifierAndFieldItr ) - > summaryIdentifier ( ) , identifierText ) ) ;
if ( ( * identifierAndFieldItr ) - > summaryIdentifier ( ) ! = RifEclipseSummaryAddress : : INPUT_VECTOR_NAME )
{
addSelectionAddress ( category , std : : next ( identifierAndFieldItr , 1 ) , addressSet , identifierPath ) ;
}
else
{
std : : map < RifEclipseSummaryAddress : : SummaryIdentifierType , std : : string > selectedIdentifiers ;
for ( const auto & identifier : identifierPath )
{
selectedIdentifiers . insert ( std : : make_pair ( identifier . first , identifier . second . toStdString ( ) ) ) ;
}
auto address = RifEclipseSummaryAddress ( category , selectedIdentifiers ) ;
addressSet . insert ( address ) ;
}
identifierPath . pop_back ( ) ;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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 > selectedAddresses = buildAddressListFromSelections ( ) ;
// Todo: Move to separate method
std : : set < RifEclipseSummaryAddress > addrUnion ;
for ( RimSummaryCase * currCase : m_selectedCases )
{
RifReaderEclipseSummary * reader = nullptr ;
if ( currCase & & currCase - > caseData ( ) ) reader = currCase - > caseData ( ) - > summaryReader ( ) ;
if ( reader )
{
const std : : vector < RifEclipseSummaryAddress > & allAddresses = reader - > allResultAddresses ( ) ;
int addressCount = static_cast < int > ( allAddresses . size ( ) ) ;
for ( int i = 0 ; i < addressCount ; i + + )
{
if ( selectedAddresses . count ( allAddresses [ i ] ) > 0 )
{
addrUnion . insert ( allAddresses [ i ] ) ;
newCurveDefinitions . insert ( std : : make_pair ( currCase , allAddresses [ i ] ) ) ;
}
// Todo: Add text filter
//if (!m_summaryFilter->isIncludedByFilter(allAddresses[i])) continue;
}
}
}
2017-09-13 10:18:15 -05:00
std : : vector < QString > curveTexts ;
2017-09-13 11:55:58 -05:00
m_previewPlot - > deleteAllTopLevelCurves ( ) ;
2017-09-13 09:31:52 -05:00
for ( const auto & curveDef : newCurveDefinitions )
{
RimSummaryCase * currentCase = curveDef . first ;
RimSummaryCurve * curve = new RimSummaryCurve ( ) ;
curve - > setSummaryCase ( currentCase ) ;
curve - > setSummaryAddress ( curveDef . second ) ;
m_previewPlot - > addCurve ( curve ) ;
2017-09-13 10:18:15 -05:00
curveTexts . push_back ( QString : : fromStdString ( curveDef . second . uiText ( ) ) ) ;
2017-09-13 09:31:52 -05:00
}
2017-09-13 10:18:15 -05:00
m_selectedCurveTexts = curveTexts ;
2017-09-13 11:55:58 -05:00
m_previewPlot - > loadDataAndUpdate ( ) ;
m_previewPlot - > updateConnectedEditors ( ) ;
m_previewPlot - > zoomAll ( ) ;
2017-09-13 10:18:15 -05:00
2017-09-13 09:31:52 -05:00
//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);
}