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.
//
/////////////////////////////////////////////////////////////////////////////////
# include "RicSummaryCurveCreator.h"
# include "RiaApplication.h"
2017-09-15 03:48:38 -05:00
# include "RicSummaryCurveCreatorUiKeywords.h"
2017-09-15 09:15:54 -05:00
# include "RicSelectSummaryPlotUI.h"
2017-09-08 07:49:41 -05:00
# include "RifReaderEclipseSummary.h"
# include "RigSummaryCaseData.h"
2017-09-15 03:48:38 -05:00
2017-09-15 06:47:15 -05:00
# include "RimMainPlotCollection.h"
2017-09-08 07:49:41 -05:00
# include "RimProject.h"
# include "RimSummaryCase.h"
# include "RimSummaryCase.h"
2017-09-15 03:48:38 -05:00
# include "RimSummaryPlot.h"
2017-09-15 06:47:15 -05:00
# include "RimSummaryPlotCollection.h"
2017-09-19 02:29:24 -05:00
# include "RimSummaryCurveCollection.h"
2017-09-15 03:48:38 -05:00
2017-09-15 09:15:54 -05:00
# include "RiuMainPlotWindow.h"
2017-09-08 07:49:41 -05:00
# include "cafPdmUiListEditor.h"
2017-09-15 06:47:15 -05:00
# include "cafPdmUiPushButtonEditor.h"
2017-09-12 04:58:49 -05:00
# include "cafPdmUiTreeSelectionEditor.h"
2017-09-15 03:48:38 -05:00
2017-09-15 09:15:54 -05:00
# include <QInputDialog>
2017-09-15 03:48:38 -05:00
# include <algorithm>
# include <sstream>
# include <stack>
2017-09-18 07:49:31 -05:00
# include "RimSummaryCaseMainCollection.h"
# include "RimOilField.h"
# include "RimSummaryCaseCollection.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-15 06:47:15 -05:00
CAF_PDM_InitFieldNoDefault ( & m_targetPlot , " TargetPlot " , " Target Plot " , " " , " " , " " ) ;
2017-09-13 10:18:15 -05:00
2017-09-14 06:14:06 -05:00
CAF_PDM_InitField ( & m_useAutoAppearanceAssignment , " UseAutoAppearanceAssignment " , true , " Auto " , " " , " " , " " ) ;
2017-09-19 08:19:48 -05:00
CAF_PDM_InitField ( & m_appearanceApplyButton , " AppearanceApplyButton " , false , " " , " " , " " , " " ) ;
2017-09-14 06:14:06 -05:00
CAF_PDM_InitFieldNoDefault ( & m_caseAppearanceType , " CaseAppearanceType " , " Case " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( & m_variableAppearanceType , " VariableAppearanceType " , " Vector " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( & m_wellAppearanceType , " WellAppearanceType " , " Well " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( & m_groupAppearanceType , " GroupAppearanceType " , " Group " , " " , " " , " " ) ;
CAF_PDM_InitFieldNoDefault ( & m_regionAppearanceType , " RegionAppearanceType " , " Region " , " " , " " , " " ) ;
//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-15 06:47:15 -05:00
CAF_PDM_InitFieldNoDefault ( & m_applyButtonField , " ApplySelection " , " " , " " , " " , " " ) ;
m_applyButtonField = false ;
m_applyButtonField . uiCapability ( ) - > setUiEditorTypeName ( caf : : PdmUiPushButtonEditor : : uiEditorTypeName ( ) ) ;
m_applyButtonField . uiCapability ( ) - > setUiLabelPosition ( caf : : PdmUiItemInfo : : HIDDEN ) ;
CAF_PDM_InitFieldNoDefault ( & m_closeButtonField , " Close " , " " , " " , " " , " " ) ;
m_closeButtonField = false ;
m_closeButtonField . uiCapability ( ) - > setUiEditorTypeName ( caf : : PdmUiPushButtonEditor : : uiEditorTypeName ( ) ) ;
m_closeButtonField . uiCapability ( ) - > setUiLabelPosition ( caf : : PdmUiItemInfo : : HIDDEN ) ;
CAF_PDM_InitField ( & m_createNewPlot , " CreateNewPlot " , false , " Create New Plot " , " " , " " , " " ) ;
2017-09-15 09:15:54 -05:00
m_createNewPlot . uiCapability ( ) - > setUiEditorTypeName ( caf : : PdmUiPushButtonEditor : : uiEditorTypeName ( ) ) ;
m_createNewPlot . uiCapability ( ) - > setUiLabelPosition ( caf : : PdmUiItemInfo : : HIDDEN ) ;
2017-09-19 08:19:48 -05:00
m_appearanceApplyButton = false ;
m_appearanceApplyButton . uiCapability ( ) - > setUiEditorTypeName ( caf : : PdmUiPushButtonEditor : : uiEditorTypeName ( ) ) ;
m_appearanceApplyButton . uiCapability ( ) - > setUiLabelPosition ( caf : : PdmUiItemInfo : : LEFT ) ;
2017-09-08 07:49:41 -05:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicSummaryCurveCreator : : ~ RicSummaryCurveCreator ( )
{
2017-09-15 04:49:09 -05:00
for ( const auto & identifierAndFieldList : m_identifierFieldsMap )
2017-09-08 07:49:41 -05:00
{
2017-09-15 04:49:09 -05:00
for ( const auto & identifierAndField : identifierAndFieldList . second )
2017-09-08 07:49:41 -05:00
{
2017-09-15 04:49:09 -05:00
delete identifierAndField - > pdmField ( ) ;
2017-09-08 07:49:41 -05:00
}
}
2017-09-18 00:46:29 -05:00
delete m_previewPlot ;
2017-09-08 07:49:41 -05:00
}
2017-09-15 04:49:09 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-09-18 00:46:29 -05:00
void RicSummaryCurveCreator : : updateFromSummaryPlot ( RimSummaryPlot * targetPlot )
2017-09-15 04:49:09 -05:00
{
2017-09-18 00:46:29 -05:00
if ( m_targetPlot ! = targetPlot )
{
resetAllFields ( ) ;
}
2017-09-15 04:49:09 -05:00
m_targetPlot = targetPlot ;
2017-09-19 08:19:48 -05:00
m_useAutoAppearanceAssignment = true ;
2017-09-18 00:46:29 -05:00
if ( m_targetPlot )
2017-09-15 06:37:52 -05:00
{
2017-09-18 00:46:29 -05:00
populateCurveCreator ( * m_targetPlot ) ;
loadDataAndUpdatePlot ( ) ;
2017-09-15 06:37:52 -05:00
}
2017-09-18 00:46:29 -05:00
2017-09-19 02:29:24 -05:00
caf : : PdmUiItem : : updateConnectedEditors ( ) ;
2017-09-15 04:49:09 -05:00
}
2017-09-15 07:40:25 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicSummaryCurveCreator : : isCloseButtonPressed ( ) const
{
return m_closeButtonField ( ) ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveCreator : : clearCloseButton ( )
{
m_closeButtonField = false ;
}
2017-09-08 07:49:41 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveCreator : : fieldChangedByUi ( const caf : : PdmFieldHandle * changedField , const QVariant & oldValue , const QVariant & newValue )
{
2017-09-15 06:47:15 -05:00
if ( changedField = = & m_applyButtonField )
{
m_applyButtonField = false ;
updateTargetPlot ( ) ;
}
2017-09-15 09:15:54 -05:00
else if ( changedField = = & m_createNewPlot )
{
m_createNewPlot = false ;
RimProject * proj = RiaApplication : : instance ( ) - > project ( ) ;
RimSummaryPlotCollection * summaryPlotColl = proj - > mainPlotCollection ( ) - > summaryPlotCollection ( ) ;
if ( summaryPlotColl )
{
QString summaryPlotName = QString ( " SummaryPlot %1 " ) . arg ( summaryPlotColl - > summaryPlots ( ) . size ( ) + 1 ) ;
bool ok = false ;
summaryPlotName = QInputDialog : : getText ( NULL , " New Summary Plot Name " , " New Summary Plot Name " , QLineEdit : : Normal , summaryPlotName , & ok ) ;
if ( ok )
{
RimSummaryPlot * plot = new RimSummaryPlot ( ) ;
summaryPlotColl - > summaryPlots ( ) . push_back ( plot ) ;
plot - > setDescription ( summaryPlotName ) ;
plot - > loadDataAndUpdate ( ) ;
summaryPlotColl - > updateConnectedEditors ( ) ;
RiuMainPlotWindow * mainPlotWindow = RiaApplication : : instance ( ) - > mainPlotWindow ( ) ;
if ( mainPlotWindow )
{
mainPlotWindow - > selectAsCurrentItem ( plot ) ;
mainPlotWindow - > setExpanded ( plot , true ) ;
}
m_createNewPlot = false ;
m_targetPlot = plot ;
updateTargetPlot ( ) ;
}
}
}
2017-09-19 08:19:48 -05:00
else if ( changedField = = & m_appearanceApplyButton )
{
applyAppearanceToAllPreviewCurves ( ) ;
m_previewPlot - > loadDataAndUpdate ( ) ;
m_appearanceApplyButton = false ;
}
2017-09-15 06:47:15 -05:00
else
{
// Lookup item type input field
2017-09-18 04:54:38 -05:00
auto identifierAndField = lookupIdentifierAndFieldFromFieldHandle ( changedField ) ;
2017-09-15 06:47:15 -05:00
if ( changedField = = & m_selectedCases | |
identifierAndField ! = nullptr )
{
loadDataAndUpdatePlot ( ) ;
}
2017-09-13 09:31:52 -05:00
}
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 ( ) ;
2017-09-18 07:49:31 -05:00
std : : vector < RimSummaryCase * > topLevelCases ;
std : : vector < RimOilField * > oilFields ;
2017-09-08 07:49:41 -05:00
2017-09-18 07:49:31 -05:00
proj - > allOilFields ( oilFields ) ;
for ( RimOilField * oilField : oilFields )
2017-09-08 07:49:41 -05:00
{
2017-09-18 07:49:31 -05:00
RimSummaryCaseMainCollection * sumCaseMainColl = oilField - > summaryCaseMainCollection ( ) ;
if ( sumCaseMainColl )
{
// Top level cases
for ( const auto & sumCase : sumCaseMainColl - > topLevelSummaryCases ( ) )
{
options . push_back ( caf : : PdmOptionItemInfo ( sumCase - > caseName ( ) , sumCase ) ) ;
}
// Grouped cases
for ( const auto & sumCaseColl : sumCaseMainColl - > summaryCaseCollections ( ) )
{
options . push_back ( caf : : PdmOptionItemInfo : : createHeader ( sumCaseColl - > name ( ) , true ) ) ;
for ( const auto & sumCase : sumCaseColl - > allSummaryCases ( ) )
{
auto optionItem = caf : : PdmOptionItemInfo ( sumCase - > caseName ( ) , sumCase ) ;
optionItem . setLevel ( 1 ) ;
options . push_back ( optionItem ) ;
}
}
// Observed cases
// Under construction...
//auto observedCases = sumCaseMainColl->topLevelSummaryCases/*observedCases*/();
//if (observedCases.size() > 0)
//{
// options.push_back(caf::PdmOptionItemInfo::createHeader("Observed Summary Cases", true));
// for (const auto& sumCase : observedCases)
// {
// auto optionItem = caf::PdmOptionItemInfo(sumCase->caseName(), sumCase);
// optionItem.setLevel(1);
// options.push_back(optionItem);
// }
//}
}
2017-09-08 07:49:41 -05:00
}
}
2017-09-15 06:47:15 -05:00
else if ( fieldNeedingOptions = = & m_targetPlot )
{
RimProject * proj = RiaApplication : : instance ( ) - > project ( ) ;
RimSummaryPlotCollection * summaryPlotColl = proj - > mainPlotCollection ( ) - > summaryPlotCollection ( ) ;
if ( summaryPlotColl )
{
summaryPlotColl - > summaryPlotItemInfos ( & options ) ;
}
}
2017-09-08 07:49:41 -05:00
else
{
2017-09-12 04:58:49 -05:00
// Lookup item type input field
2017-09-18 04:54:38 -05:00
auto identifierAndField = lookupIdentifierAndFieldFromFieldHandle ( fieldNeedingOptions ) ;
2017-09-12 12:51:45 -05:00
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-15 04:49:09 -05:00
auto name = QString : : fromStdString ( address . uiText ( identifierAndField - > summaryIdentifier ( ) ) ) ;
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-15 01:30:29 -05:00
{
2017-09-08 07:49:41 -05:00
options . push_back ( caf : : PdmOptionItemInfo ( iName , iName ) ) ;
2017-09-15 01:30:29 -05:00
}
2017-09-08 07:49:41 -05:00
}
}
return options ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveCreator : : defineUiOrdering ( QString uiConfigName , caf : : PdmUiOrdering & uiOrdering )
{
2017-09-15 03:48:38 -05:00
caf : : PdmUiGroup * sourcesGroup = uiOrdering . addNewGroupWithKeyword ( " Sources " , RicSummaryCurveCreatorUiKeywords : : sources ( ) ) ;
2017-09-08 07:49:41 -05:00
sourcesGroup - > add ( & m_selectedCases ) ;
2017-09-15 03:48:38 -05:00
caf : : PdmUiGroup * itemTypesGroup = uiOrdering . addNewGroupWithKeyword ( " Identifier Types " , RicSummaryCurveCreatorUiKeywords : : summaryTypes ( ) ) ;
2017-09-12 12:51:45 -05:00
itemTypesGroup - > add ( & m_selectedSummaryCategory ) ;
2017-09-08 07:49:41 -05:00
2017-09-15 03:48:38 -05:00
caf : : PdmField < std : : vector < QString > > * summaryiesField = nullptr ;
2017-09-13 08:22:16 -05:00
RifEclipseSummaryAddress : : SummaryVarCategory sumCategory = m_selectedSummaryCategory ( ) ;
if ( sumCategory = = RifEclipseSummaryAddress : : SUMMARY_FIELD )
{
2017-09-15 03:48:38 -05:00
summaryiesField = m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_FIELD ] [ 0 ] - > pdmField ( ) ;
2017-09-13 08:22:16 -05:00
}
else if ( sumCategory = = RifEclipseSummaryAddress : : SUMMARY_AQUIFER )
{
2017-09-15 03:48:38 -05:00
summaryiesField = m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_AQUIFER ] [ 0 ] - > pdmField ( ) ;
2017-09-13 08:22:16 -05:00
}
else if ( sumCategory = = RifEclipseSummaryAddress : : SUMMARY_NETWORK )
{
2017-09-15 03:48:38 -05:00
summaryiesField = m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_NETWORK ] [ 0 ] - > pdmField ( ) ;
2017-09-13 08:22:16 -05:00
}
else if ( sumCategory = = RifEclipseSummaryAddress : : SUMMARY_MISC )
{
2017-09-15 03:48:38 -05:00
summaryiesField = m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_MISC ] [ 0 ] - > pdmField ( ) ;
2017-09-13 08:22:16 -05:00
}
else if ( sumCategory = = RifEclipseSummaryAddress : : SUMMARY_REGION )
{
{
2017-09-15 03:48:38 -05:00
caf : : PdmUiGroup * myGroup = uiOrdering . addNewGroupWithKeyword ( " Regions " , " RegionsKeyword " ) ;
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-15 03:48:38 -05:00
summaryiesField = 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-15 03:48:38 -05:00
summaryiesField = 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-15 03:48:38 -05:00
summaryiesField = 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-15 03:48:38 -05:00
summaryiesField = 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-15 03:48:38 -05:00
summaryiesField = 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-15 03:48:38 -05:00
summaryiesField = 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-15 03:48:38 -05:00
summaryiesField = 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-15 03:48:38 -05:00
summaryiesField = 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-15 03:48:38 -05:00
summaryiesField = 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-15 03:48:38 -05:00
summaryiesField = m_identifierFieldsMap [ RifEclipseSummaryAddress : : SUMMARY_BLOCK_LGR ] [ 2 ] - > pdmField ( ) ;
2017-09-13 08:22:16 -05:00
}
2017-09-15 03:48:38 -05:00
CAF_ASSERT ( summaryiesField ) ;
caf : : PdmUiGroup * summariesGroup = uiOrdering . addNewGroupWithKeyword ( " Summaries " , RicSummaryCurveCreatorUiKeywords : : summaries ( ) ) ;
summariesGroup - > add ( summaryiesField ) ;
2017-09-14 06:14:06 -05:00
// Appearance settings
2017-09-15 03:48:38 -05:00
caf : : PdmUiGroup * appearanceGroup = uiOrdering . addNewGroupWithKeyword ( " Appearance Settings " , RicSummaryCurveCreatorUiKeywords : : appearance ( ) ) ;
2017-09-19 04:11:01 -05:00
appearanceGroup - > setCollapsedByDefault ( true ) ;
2017-09-14 06:14:06 -05:00
appearanceGroup - > add ( & m_useAutoAppearanceAssignment ) ;
appearanceGroup - > add ( & m_caseAppearanceType ) ;
appearanceGroup - > add ( & m_variableAppearanceType ) ;
appearanceGroup - > add ( & m_wellAppearanceType ) ;
appearanceGroup - > add ( & m_groupAppearanceType ) ;
appearanceGroup - > add ( & m_regionAppearanceType ) ;
2017-09-19 08:19:48 -05:00
appearanceGroup - > add ( & m_appearanceApplyButton ) ;
2017-09-14 06:14:06 -05:00
// Appearance option sensitivity
{
m_caseAppearanceType . uiCapability ( ) - > setUiReadOnly ( m_useAutoAppearanceAssignment ) ;
m_variableAppearanceType . uiCapability ( ) - > setUiReadOnly ( m_useAutoAppearanceAssignment ) ;
m_wellAppearanceType . uiCapability ( ) - > setUiReadOnly ( m_useAutoAppearanceAssignment ) ;
m_groupAppearanceType . uiCapability ( ) - > setUiReadOnly ( m_useAutoAppearanceAssignment ) ;
m_regionAppearanceType . uiCapability ( ) - > setUiReadOnly ( m_useAutoAppearanceAssignment ) ;
}
2017-09-13 08:22:16 -05:00
2017-09-15 06:47:15 -05:00
// Fields to be displayed directly in UI
uiOrdering . add ( & m_createNewPlot ) ;
uiOrdering . add ( & m_targetPlot ) ;
uiOrdering . add ( & m_applyButtonField ) ;
uiOrdering . add ( & m_closeButtonField ) ;
m_targetPlot . uiCapability ( ) - > setUiReadOnly ( m_createNewPlot ) ;
2017-09-13 08:22:16 -05:00
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-15 01:30:29 -05:00
{
2017-09-12 04:58:49 -05:00
return addrUnion ;
2017-09-15 01:30:29 -05:00
}
2017-09-12 04:58:49 -05:00
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 ) ;
2017-09-18 04:54:38 -05:00
std : : vector < SummaryIdentifierAndField * > controllingFields ;
2017-09-13 03:14:18 -05:00
if ( applySelections )
2017-09-12 04:58:49 -05:00
{
// Build selections vector
2017-09-18 04:54:38 -05:00
controllingFields = 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-18 04:54:38 -05:00
bool addressSelected = applySelections ? isAddressCompatibleWithControllingFieldSelection ( allAddresses [ i ] , controllingFields ) : 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 )
2017-09-15 01:30:29 -05:00
{
2017-09-12 04:58:49 -05:00
addrUnion . insert ( allAddresses [ i ] ) ;
2017-09-15 01:30:29 -05:00
}
2017-09-12 04:58:49 -05:00
}
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-18 04:54:38 -05:00
std : : vector < RicSummaryCurveCreator : : SummaryIdentifierAndField * > controllingFields ;
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-15 01:30:29 -05:00
{
2017-09-12 04:58:49 -05:00
break ;
2017-09-15 01:30:29 -05:00
}
2017-09-18 04:54:38 -05:00
controllingFields . push_back ( identifierAndFieldItem ) ;
2017-09-12 04:58:49 -05:00
}
2017-09-18 04:54:38 -05:00
return controllingFields ;
2017-09-12 04:58:49 -05:00
}
2017-09-08 07:49:41 -05:00
//--------------------------------------------------------------------------------------------------
2017-09-18 04:54:38 -05:00
///
2017-09-08 07:49:41 -05:00
//--------------------------------------------------------------------------------------------------
2017-09-18 04:54:38 -05:00
RicSummaryCurveCreator : : SummaryIdentifierAndField * RicSummaryCurveCreator : : lookupIdentifierAndFieldFromFieldHandle ( 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 ( ) )
2017-09-15 01:30:29 -05:00
{
2017-09-08 07:49:41 -05:00
return itemTypeInput ;
2017-09-15 01:30:29 -05:00
}
2017-09-08 07:49:41 -05:00
}
}
return nullptr ;
}
//--------------------------------------------------------------------------------------------------
2017-09-18 04:54:38 -05:00
/// Returns the Controlling pdm field info for the specified pdm field info.
/// Controlling means the field controlling the dependent field
2017-09-08 07:49:41 -05:00
/// If the specified pdm field info is the topmost (i.e. index is 0), null pointer is returned
//--------------------------------------------------------------------------------------------------
2017-09-18 04:54:38 -05:00
RicSummaryCurveCreator : : SummaryIdentifierAndField * RicSummaryCurveCreator : : lookupControllingField ( const RicSummaryCurveCreator : : SummaryIdentifierAndField * dependentField )
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-18 04:54:38 -05:00
if ( iaf = = dependentField )
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-18 04:54:38 -05:00
///
2017-09-08 07:49:41 -05:00
//--------------------------------------------------------------------------------------------------
2017-09-18 04:54:38 -05:00
bool RicSummaryCurveCreator : : isAddressCompatibleWithControllingFieldSelection ( 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-15 04:49:09 -05:00
for ( const auto & selectedText : identifierAndField - > pdmField ( ) - > v ( ) )
2017-09-08 07:49:41 -05:00
{
2017-09-15 04:49:09 -05:00
if ( QString : : compare ( QString : : fromStdString ( address . uiText ( identifierAndField - > summaryIdentifier ( ) ) ) , selectedText ) = = 0 )
2017-09-12 04:58:49 -05:00
{
match = true ;
break ;
}
2017-09-08 07:49:41 -05:00
}
2017-09-18 04:54:38 -05:00
2017-09-12 04:58:49 -05:00
if ( ! match )
2017-09-15 01:30:29 -05:00
{
2017-09-12 04:58:49 -05:00
return false ;
2017-09-15 01:30:29 -05:00
}
2017-09-08 07:49:41 -05:00
}
2017-09-18 04:54:38 -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
2017-09-18 04:54:38 -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 ;
2017-09-18 04:54:38 -05:00
buildAddressListForCategoryRecursively ( identifierAndFieldList . first , identifierAndFieldList . second . begin ( ) , addressSet , selectionStack ) ;
2017-09-13 09:31:52 -05:00
}
return addressSet ;
}
2017-09-18 04:54:38 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveCreator : : buildAddressListForCategoryRecursively ( RifEclipseSummaryAddress : : SummaryVarCategory category ,
2017-09-14 00:43:56 -05:00
std : : vector < SummaryIdentifierAndField * > : : const_iterator identifierAndFieldItr ,
2017-09-13 09:31:52 -05:00
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 )
{
2017-09-18 04:54:38 -05:00
buildAddressListForCategoryRecursively ( category , std : : next ( identifierAndFieldItr , 1 ) , addressSet , identifierPath ) ;
2017-09-13 09:31:52 -05:00
}
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 ( ) ;
}
}
//--------------------------------------------------------------------------------------------------
2017-09-14 06:14:06 -05:00
///
2017-09-13 09:31:52 -05:00
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveCreator : : loadDataAndUpdatePlot ( )
{
2017-09-18 04:54:38 -05:00
syncPreviewCurvesFromUiSelection ( ) ;
2017-09-13 09:31:52 -05:00
}
//--------------------------------------------------------------------------------------------------
2017-09-14 06:14:06 -05:00
///
2017-09-13 09:31:52 -05:00
//--------------------------------------------------------------------------------------------------
2017-09-18 04:54:38 -05:00
void RicSummaryCurveCreator : : syncPreviewCurvesFromUiSelection ( )
2017-09-13 09:31:52 -05:00
{
// Create a search map containing whats supposed to be curves
2017-09-14 08:40:41 -05:00
std : : set < std : : pair < RimSummaryCase * , RifEclipseSummaryAddress > > allCurveDefinitions ;
2017-09-13 09:31:52 -05:00
// Populate the newCurveDefinitions from the Gui
std : : set < RifEclipseSummaryAddress > selectedAddresses = buildAddressListFromSelections ( ) ;
2017-09-19 08:19:48 -05:00
// Find the addresses to display
2017-09-13 09:31:52 -05:00
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 ] ) ;
2017-09-14 08:40:41 -05:00
allCurveDefinitions . insert ( std : : make_pair ( currCase , allAddresses [ i ] ) ) ;
2017-09-13 09:31:52 -05:00
}
}
}
}
2017-09-18 04:54:38 -05:00
std : : vector < RimSummaryCurve * > currentCurvesInPreviewPlot = m_previewPlot - > summaryCurves ( ) ;
if ( allCurveDefinitions . size ( ) ! = currentCurvesInPreviewPlot . size ( ) )
2017-09-14 08:40:41 -05:00
{
std : : set < std : : pair < RimSummaryCase * , RifEclipseSummaryAddress > > currentCurveDefs ;
std : : set < std : : pair < RimSummaryCase * , RifEclipseSummaryAddress > > newCurveDefs ;
2017-09-18 04:54:38 -05:00
std : : set < RimSummaryCurve * > curvesToDelete ;
2017-09-14 08:40:41 -05:00
2017-09-18 04:54:38 -05:00
for ( const auto & curve : currentCurvesInPreviewPlot )
2017-09-14 08:40:41 -05:00
{
currentCurveDefs . insert ( std : : make_pair ( curve - > summaryCase ( ) , curve - > summaryAddress ( ) ) ) ;
}
2017-09-18 04:54:38 -05:00
if ( allCurveDefinitions . size ( ) < currentCurvesInPreviewPlot . size ( ) )
2017-09-14 08:40:41 -05:00
{
// Determine which curves to delete from plot
std : : set < std : : pair < RimSummaryCase * , RifEclipseSummaryAddress > > deleteCurveDefs ;
std : : set_difference ( currentCurveDefs . begin ( ) , currentCurveDefs . end ( ) ,
allCurveDefinitions . begin ( ) , allCurveDefinitions . end ( ) ,
std : : inserter ( deleteCurveDefs , deleteCurveDefs . end ( ) ) ) ;
2017-09-18 04:54:38 -05:00
for ( const auto & curve : currentCurvesInPreviewPlot )
2017-09-14 08:40:41 -05:00
{
std : : pair < RimSummaryCase * , RifEclipseSummaryAddress > curveDef = std : : make_pair ( curve - > summaryCase ( ) , curve - > summaryAddress ( ) ) ;
2017-09-18 03:45:31 -05:00
if ( deleteCurveDefs . count ( curveDef ) > 0 )
2017-09-18 04:54:38 -05:00
curvesToDelete . insert ( curve ) ;
2017-09-14 08:40:41 -05:00
}
}
else
{
// Determine which curves are new since last time
std : : set_difference ( allCurveDefinitions . begin ( ) , allCurveDefinitions . end ( ) ,
currentCurveDefs . begin ( ) , currentCurveDefs . end ( ) ,
std : : inserter ( newCurveDefs , newCurveDefs . end ( ) ) ) ;
}
2017-09-18 04:54:38 -05:00
2017-09-19 08:19:48 -05:00
updatePreviewCurvesFromCurveDefinitions ( allCurveDefinitions , newCurveDefs , curvesToDelete ) ;
2017-09-14 08:40:41 -05:00
}
2017-09-14 06:14:06 -05:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-09-19 08:19:48 -05:00
void RicSummaryCurveCreator : : updatePreviewCurvesFromCurveDefinitions ( const std : : set < std : : pair < RimSummaryCase * , RifEclipseSummaryAddress > > & allCurveDefsToDisplay ,
const std : : set < std : : pair < RimSummaryCase * , RifEclipseSummaryAddress > > & curveDefsToAdd ,
2017-09-18 04:54:38 -05:00
const std : : set < RimSummaryCurve * > & curvesToDelete )
2017-09-14 06:14:06 -05:00
{
RimSummaryCase * prevCase = nullptr ;
RimPlotCurve : : LineStyleEnum lineStyle = RimPlotCurve : : STYLE_SOLID ;
2017-09-19 08:19:48 -05:00
RimSummaryCurveAppearanceCalculator curveLookCalc ( allCurveDefsToDisplay , getAllSummaryCaseNames ( ) , getAllSummaryWellNames ( ) ) ;
2017-09-14 06:14:06 -05:00
2017-09-19 08:19:48 -05:00
initCurveAppearanceCalculator ( curveLookCalc ) ;
2017-09-14 06:14:06 -05:00
2017-09-14 08:40:41 -05:00
// Delete curves
for ( const auto & curve : curvesToDelete )
{
m_previewPlot - > deleteCurve ( curve ) ;
}
2017-09-14 06:14:06 -05:00
// Add new curves
2017-09-14 08:40:41 -05:00
for ( const auto & curveDef : curveDefsToAdd )
2017-09-13 09:31:52 -05:00
{
RimSummaryCase * currentCase = curveDef . first ;
RimSummaryCurve * curve = new RimSummaryCurve ( ) ;
2017-09-14 06:14:06 -05:00
curve - > setSummaryCase ( currentCase ) ;
2017-09-13 09:31:52 -05:00
curve - > setSummaryAddress ( curveDef . second ) ;
m_previewPlot - > addCurve ( curve ) ;
2017-09-14 06:14:06 -05:00
curveLookCalc . setupCurveLook ( curve ) ;
2017-09-13 09:31:52 -05:00
}
2017-09-13 11:55:58 -05:00
m_previewPlot - > loadDataAndUpdate ( ) ;
m_previewPlot - > zoomAll ( ) ;
2017-09-19 02:29:24 -05:00
updateEditorsConnectedToPreviewPlot ( ) ;
2017-09-14 06:14:06 -05:00
}
2017-09-13 09:31:52 -05:00
2017-09-14 06:14:06 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std : : set < std : : string > RicSummaryCurveCreator : : getAllSummaryCaseNames ( )
{
std : : set < std : : string > summaryCaseHashes ;
RimProject * proj = RiaApplication : : instance ( ) - > project ( ) ;
std : : vector < RimSummaryCase * > cases ;
2017-09-13 09:31:52 -05:00
2017-09-14 06:14:06 -05:00
proj - > allSummaryCases ( cases ) ;
for ( RimSummaryCase * rimCase : cases )
{
summaryCaseHashes . insert ( rimCase - > summaryHeaderFilename ( ) . toUtf8 ( ) . constData ( ) ) ;
}
return summaryCaseHashes ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std : : set < std : : string > RicSummaryCurveCreator : : getAllSummaryWellNames ( )
{
std : : set < std : : string > summaryWellNames ;
RimProject * proj = RiaApplication : : instance ( ) - > project ( ) ;
std : : vector < RimSummaryCase * > cases ;
proj - > allSummaryCases ( cases ) ;
for ( RimSummaryCase * rimCase : cases )
{
RifReaderEclipseSummary * reader = nullptr ;
if ( rimCase & & rimCase - > caseData ( ) )
{
reader = rimCase - > caseData ( ) - > summaryReader ( ) ;
}
if ( reader )
{
const std : : vector < RifEclipseSummaryAddress > allAddresses = reader - > allResultAddresses ( ) ;
for ( size_t i = 0 ; i < allAddresses . size ( ) ; i + + )
{
if ( allAddresses [ i ] . category ( ) = = RifEclipseSummaryAddress : : SUMMARY_WELL )
{
summaryWellNames . insert ( allAddresses [ i ] . wellName ( ) ) ;
}
}
}
}
return summaryWellNames ;
2017-09-13 09:31:52 -05:00
}
2017-09-15 04:49:09 -05:00
2017-09-15 06:47:15 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveCreator : : defineEditorAttribute ( const caf : : PdmFieldHandle * field , QString uiConfigName , caf : : PdmUiEditorAttribute * attribute )
{
if ( & m_applyButtonField = = field )
{
caf : : PdmUiPushButtonEditorAttribute * attrib = dynamic_cast < caf : : PdmUiPushButtonEditorAttribute * > ( attribute ) ;
if ( attrib )
{
attrib - > m_buttonText = " Apply " ;
}
}
else if ( & m_closeButtonField = = field )
{
caf : : PdmUiPushButtonEditorAttribute * attrib = dynamic_cast < caf : : PdmUiPushButtonEditorAttribute * > ( attribute ) ;
if ( attrib )
{
2017-09-15 09:15:54 -05:00
attrib - > m_buttonText = " Cancel " ;
}
}
else if ( & m_createNewPlot = = field )
{
caf : : PdmUiPushButtonEditorAttribute * attrib = dynamic_cast < caf : : PdmUiPushButtonEditorAttribute * > ( attribute ) ;
if ( attrib )
{
attrib - > m_buttonText = " New Plot " ;
2017-09-15 06:47:15 -05:00
}
}
2017-09-19 08:19:48 -05:00
else if ( & m_appearanceApplyButton = = field )
{
caf : : PdmUiPushButtonEditorAttribute * attrib = dynamic_cast < caf : : PdmUiPushButtonEditorAttribute * > ( attribute ) ;
if ( attrib )
{
attrib - > m_buttonText = " Apply " ;
}
}
2017-09-15 06:47:15 -05:00
}
2017-09-15 07:40:25 -05:00
2017-09-15 04:49:09 -05:00
//--------------------------------------------------------------------------------------------------
/// Populate curve creator from the given curve collection
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveCreator : : populateCurveCreator ( const RimSummaryPlot & sourceSummaryPlot )
{
2017-09-15 07:34:33 -05:00
m_previewPlot - > deleteAllSummaryCurves ( ) ;
2017-09-15 04:49:09 -05:00
for ( const auto & curve : sourceSummaryPlot . summaryCurves ( ) )
{
// Select case if not already selected
2017-09-15 06:37:52 -05:00
if ( std : : find ( m_selectedCases . begin ( ) , m_selectedCases . end ( ) , curve - > summaryCase ( ) ) = = m_selectedCases . end ( ) )
2017-09-15 04:49:09 -05:00
{
m_selectedCases . push_back ( curve - > summaryCase ( ) ) ;
}
auto identifierAndFieldList = m_identifierFieldsMap [ curve - > summaryAddress ( ) . category ( ) ] ;
for ( const auto & identifierAndField : identifierAndFieldList )
{
2017-09-15 06:37:52 -05:00
QString uiText = QString : : fromStdString ( curve - > summaryAddress ( ) . uiText ( identifierAndField - > summaryIdentifier ( ) ) ) ;
const auto & currentSelectionVector = identifierAndField - > pdmField ( ) - > v ( ) ;
if ( std : : find ( currentSelectionVector . begin ( ) , currentSelectionVector . end ( ) , uiText ) = = currentSelectionVector . end ( ) )
{
std : : vector < QString > newSelectionVector ( currentSelectionVector . begin ( ) , currentSelectionVector . end ( ) ) ;
newSelectionVector . push_back ( uiText ) ;
( * identifierAndField - > pdmField ( ) ) = newSelectionVector ;
}
2017-09-15 04:49:09 -05:00
}
2017-09-15 06:37:52 -05:00
// Copy curve object to the preview plot
2017-09-18 03:45:31 -05:00
copyCurveAndAddToPlot ( curve , m_previewPlot , true ) ;
2017-09-15 04:49:09 -05:00
}
2017-09-18 04:54:38 -05:00
2017-09-18 09:11:44 -05:00
syncPreviewCurvesFromUiSelection ( ) ;
// Set visibility for imported curves which were not checked in source plot
std : : set < std : : pair < RimSummaryCase * , RifEclipseSummaryAddress > > sourceCurveDefs ;
for ( const auto & curve : sourceSummaryPlot . summaryCurves ( ) )
{
sourceCurveDefs . insert ( std : : make_pair ( curve - > summaryCase ( ) , curve - > summaryAddress ( ) ) ) ;
}
for ( const auto & curve : m_previewPlot - > summaryCurves ( ) )
{
auto curveDef = std : : make_pair ( curve - > summaryCase ( ) , curve - > summaryAddress ( ) ) ;
if ( sourceCurveDefs . count ( curveDef ) = = 0 )
curve - > setCurveVisiblity ( false ) ;
}
2017-09-19 02:29:24 -05:00
updateEditorsConnectedToPreviewPlot ( ) ;
2017-09-19 08:19:48 -05:00
updateAppearanceEditor ( ) ;
2017-09-15 04:49:09 -05:00
}
//--------------------------------------------------------------------------------------------------
2017-09-15 07:34:33 -05:00
/// Copy curves from preview plot to target plot
2017-09-15 04:49:09 -05:00
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveCreator : : updateTargetPlot ( )
{
if ( m_targetPlot = = nullptr )
m_targetPlot = new RimSummaryPlot ( ) ;
2017-09-18 03:45:31 -05:00
2017-09-19 08:19:48 -05:00
m_targetPlot - > deleteAllSummaryCurves ( ) ;
2017-09-18 03:45:31 -05:00
2017-09-19 08:19:48 -05:00
// Add edited curves to target plot
2017-09-18 03:45:31 -05:00
for ( const auto & editedCurve : m_previewPlot - > summaryCurves ( ) )
{
if ( ! editedCurve - > isCurveVisible ( ) )
{
continue ;
}
2017-09-19 08:19:48 -05:00
copyCurveAndAddToPlot ( editedCurve , m_targetPlot ) ;
2017-09-15 04:49:09 -05:00
}
2017-09-15 07:34:33 -05:00
m_targetPlot - > updateConnectedEditors ( ) ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-09-18 03:45:31 -05:00
void RicSummaryCurveCreator : : copyCurveAndAddToPlot ( const RimSummaryCurve * curve , RimSummaryPlot * plot , bool forceVisible )
2017-09-15 07:34:33 -05:00
{
RimSummaryCurve * curveCopy = dynamic_cast < RimSummaryCurve * > ( curve - > xmlCapability ( ) - > copyByXmlSerialization ( caf : : PdmDefaultObjectFactory : : instance ( ) ) ) ;
CVF_ASSERT ( curveCopy ) ;
2017-09-18 03:45:31 -05:00
if ( forceVisible )
curveCopy - > setCurveVisiblity ( true ) ;
2017-09-15 07:34:33 -05:00
plot - > addCurve ( curveCopy ) ;
// Resolve references after object has been inserted into the project data model
curveCopy - > resolveReferencesRecursively ( ) ;
// The curve creator is not a descendant of the project, and need to be set manually
curveCopy - > setSummaryCase ( curve - > summaryCase ( ) ) ;
curveCopy - > initAfterReadRecursively ( ) ;
curveCopy - > loadDataAndUpdate ( ) ;
2017-09-15 04:49:09 -05:00
}
2017-09-18 00:46:29 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveCreator : : resetAllFields ( )
{
m_selectedCases . clear ( ) ;
m_previewPlot - > deleteAllSummaryCurves ( ) ;
m_targetPlot = nullptr ;
// clear all state in fields
for ( auto & identifierAndFieldList : m_identifierFieldsMap )
{
for ( auto a : identifierAndFieldList . second )
{
a - > pdmField ( ) - > v ( ) . clear ( ) ;
}
}
}
2017-09-19 02:29:24 -05:00
2017-09-19 08:19:48 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-09-19 02:29:24 -05:00
void RicSummaryCurveCreator : : updateEditorsConnectedToPreviewPlot ( )
{
m_previewPlot - > updateConnectedEditors ( ) ;
m_previewPlot - > summaryCurveCollection ( ) - > updateConnectedEditors ( ) ;
}
2017-09-19 08:19:48 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveCreator : : initCurveAppearanceCalculator ( RimSummaryCurveAppearanceCalculator & curveAppearanceCalc )
{
if ( ! m_useAutoAppearanceAssignment ( ) )
{
curveAppearanceCalc . assignDimensions ( m_caseAppearanceType ( ) ,
m_variableAppearanceType ( ) ,
m_wellAppearanceType ( ) ,
m_groupAppearanceType ( ) ,
m_regionAppearanceType ( ) ) ;
}
else
{
RimSummaryCurveAppearanceCalculator : : CurveAppearanceType caseAppearance ;
RimSummaryCurveAppearanceCalculator : : CurveAppearanceType variAppearance ;
RimSummaryCurveAppearanceCalculator : : CurveAppearanceType wellAppearance ;
RimSummaryCurveAppearanceCalculator : : CurveAppearanceType gropAppearance ;
RimSummaryCurveAppearanceCalculator : : CurveAppearanceType regiAppearance ;
curveAppearanceCalc . getDimensions ( & caseAppearance ,
& variAppearance ,
& wellAppearance ,
& gropAppearance ,
& regiAppearance ) ;
m_caseAppearanceType = caseAppearance ;
m_variableAppearanceType = variAppearance ;
m_wellAppearanceType = wellAppearance ;
m_groupAppearanceType = gropAppearance ;
m_regionAppearanceType = regiAppearance ;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveCreator : : applyAppearanceToAllPreviewCurves ( )
{
std : : set < std : : pair < RimSummaryCase * , RifEclipseSummaryAddress > > allCurveDefs = allPreviewCurveDefs ( ) ;
RimSummaryCurveAppearanceCalculator curveLookCalc ( allCurveDefs , getAllSummaryCaseNames ( ) , getAllSummaryWellNames ( ) ) ;
initCurveAppearanceCalculator ( curveLookCalc ) ;
for ( auto & curve : m_previewPlot - > summaryCurves ( ) )
{
curve - > resetAppearance ( ) ;
curveLookCalc . setupCurveLook ( curve ) ;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryCurveCreator : : updateAppearanceEditor ( )
{
std : : set < std : : pair < RimSummaryCase * , RifEclipseSummaryAddress > > allCurveDefs = allPreviewCurveDefs ( ) ;
RimSummaryCurveAppearanceCalculator curveLookCalc ( allCurveDefs , getAllSummaryCaseNames ( ) , getAllSummaryWellNames ( ) ) ;
initCurveAppearanceCalculator ( curveLookCalc ) ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std : : set < std : : pair < RimSummaryCase * , RifEclipseSummaryAddress > > RicSummaryCurveCreator : : allPreviewCurveDefs ( ) const
{
std : : set < std : : pair < RimSummaryCase * , RifEclipseSummaryAddress > > allCurveDefs ;
for ( const auto & curve : m_previewPlot - > summaryCurves ( ) )
{
allCurveDefs . insert ( std : : make_pair ( curve - > summaryCase ( ) , curve - > summaryAddress ( ) ) ) ;
}
return allCurveDefs ;
}