mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 15:10:22 -05:00
new_summary_plot() with an ensemble and an address string created an empty plot. The address filters were applied to an empty list of summary cases, and no curve sets were created. Use the summary cases of the ensemble, and make sure the summary addresses are created before the address filters are applied. Add example script showing how to create summary plots for an ensemble.
111 lines
4.3 KiB
C++
111 lines
4.3 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (C) 2020- Equinor 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 "RimcSummaryPlotCollection.h"
|
|
|
|
#include "Summary/RiaSummaryPlotTools.h"
|
|
#include "SummaryPlotCommands/RicNewDefaultSummaryPlotFeature.h"
|
|
#include "SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.h"
|
|
#include "SummaryPlotCommands/RicSummaryPlotFeatureImpl.h"
|
|
|
|
#include "RiaTextStringTools.h"
|
|
|
|
#include "RimSummaryCase.h"
|
|
#include "RimSummaryEnsemble.h"
|
|
#include "RimSummaryPlot.h"
|
|
#include "RimSummaryPlotCollection.h"
|
|
|
|
#include "RifSummaryReaderInterface.h"
|
|
|
|
#include "cafPdmAbstractFieldScriptingCapability.h"
|
|
#include "cafPdmFieldScriptingCapability.h"
|
|
|
|
#include <QStringList>
|
|
|
|
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimSummaryPlotCollection, RimcSummaryPlotCollection_newSummaryPlot, "NewSummaryPlot" );
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimcSummaryPlotCollection_newSummaryPlot::RimcSummaryPlotCollection_newSummaryPlot( caf::PdmObjectHandle* self )
|
|
: caf::PdmObjectCreationMethod( self )
|
|
{
|
|
CAF_PDM_InitObject( "Create Summary Plot", "", "", "Create a new Summary Plot" );
|
|
|
|
CAF_PDM_InitScriptableFieldNoDefault( &m_summaryCases, "SummaryCases", "", "", "", "Summary Cases" );
|
|
CAF_PDM_InitScriptableFieldNoDefault( &m_ensemble, "Ensemble", "", "", "", "Ensemble" );
|
|
CAF_PDM_InitScriptableFieldNoDefault( &m_addressString, "Address", "", "", "", "Formatted address string specifying the plot options" );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
std::expected<caf::PdmObjectHandle*, QString> RimcSummaryPlotCollection_newSummaryPlot::execute()
|
|
{
|
|
QStringList addressStrings = RiaTextStringTools::splitSkipEmptyParts( m_addressString(), ";" );
|
|
|
|
RimSummaryPlot* newPlot = nullptr;
|
|
if ( m_ensemble )
|
|
{
|
|
if ( !addressStrings.empty() )
|
|
{
|
|
auto summaryCases = m_ensemble->allSummaryCases();
|
|
|
|
// Summary addresses are created on demand, make sure they are available before applying address filters
|
|
for ( auto summaryCase : summaryCases )
|
|
{
|
|
if ( auto reader = summaryCase ? summaryCase->summaryReader() : nullptr ) reader->createAddressesIfRequired();
|
|
}
|
|
|
|
newPlot = RicSummaryPlotFeatureImpl::createSummaryPlotForEnsemble( summaryCases, m_ensemble, addressStrings );
|
|
}
|
|
else
|
|
{
|
|
newPlot = RicNewSummaryEnsembleCurveSetFeature::createPlotForCurveSetsAndUpdate( { m_ensemble } );
|
|
}
|
|
}
|
|
if ( !m_summaryCases.empty() )
|
|
{
|
|
std::vector<RimSummaryCase*> summaryCases = m_summaryCases.ptrReferencedObjectsByType();
|
|
if ( !addressStrings.empty() )
|
|
{
|
|
newPlot = RicSummaryPlotFeatureImpl::createSummaryPlotForCases( summaryCases, addressStrings );
|
|
}
|
|
else
|
|
{
|
|
newPlot = RicNewDefaultSummaryPlotFeature::createFromSummaryCases( summaryCases );
|
|
}
|
|
}
|
|
|
|
if ( newPlot )
|
|
{
|
|
newPlot->loadDataAndUpdate();
|
|
RiaSummaryPlotTools::createAndAppendSingleSummaryMultiPlot( newPlot );
|
|
}
|
|
|
|
return newPlot;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
QString RimcSummaryPlotCollection_newSummaryPlot::classKeywordReturnedType() const
|
|
{
|
|
return RimSummaryPlot::classKeywordStatic();
|
|
}
|