mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Python: Create summary plot from string
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include "RicNewSummaryEnsembleCurveSetFeature.h"
|
||||
#include "RicSummaryPlotEditorDialog.h"
|
||||
#include "RicSummaryPlotEditorUi.h"
|
||||
#include "RicSummaryPlotFeatureImpl.h"
|
||||
|
||||
#include "RimEnsembleCurveFilter.h"
|
||||
#include "RimEnsembleCurveFilterCollection.h"
|
||||
@@ -40,8 +41,6 @@
|
||||
|
||||
#include "RiuPlotMainWindow.h"
|
||||
|
||||
#include "cafPdmFieldIOScriptability.h"
|
||||
#include "cafPdmFieldScriptability.h"
|
||||
#include "cafSelectionManagerTools.h"
|
||||
#include "cvfAssert.h"
|
||||
|
||||
@@ -288,42 +287,3 @@ void RicNewDefaultSummaryPlotFeature::setupActionLook( QAction* actionToSetup )
|
||||
}
|
||||
actionToSetup->setIcon( QIcon( ":/SummaryPlotLight16x16.png" ) );
|
||||
}
|
||||
|
||||
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimSummaryPlotCollection, RimSummaryPlotCollection_newSummaryPlot, "NewSummaryPlot" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryPlotCollection_newSummaryPlot::RimSummaryPlotCollection_newSummaryPlot( caf::PdmObjectHandle* self )
|
||||
: caf::PdmObjectMethod( self )
|
||||
{
|
||||
CAF_PDM_InitObject( "Create Summary Plot", "", "", "Create a new Summary Plot" );
|
||||
CAF_PDM_InitScriptableFieldWithIONoDefault( &m_summaryCases, "SummaryCases", "", "", "", "Summary Cases" );
|
||||
CAF_PDM_InitScriptableFieldWithIONoDefault( &m_ensembles, "Ensembles", "", "", "", "Ensembles" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmObjectHandle* RimSummaryPlotCollection_newSummaryPlot::execute()
|
||||
{
|
||||
if ( !m_summaryCases.empty() )
|
||||
{
|
||||
return RicNewDefaultSummaryPlotFeature::createFromSummaryCases( self<RimSummaryPlotCollection>(),
|
||||
m_summaryCases.ptrReferencedObjects() );
|
||||
}
|
||||
else if ( !m_ensembles.empty() )
|
||||
{
|
||||
return RicNewSummaryEnsembleCurveSetFeature::createPlotForCurveSetsAndUpdate( m_ensembles.ptrReferencedObjects() );
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimSummaryPlotCollection_newSummaryPlot::deleteObjectAfterReply() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include "RicfCommandObject.h"
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
#include "cafPdmPtrArrayField.h"
|
||||
|
||||
class RimSummaryPlotCollection;
|
||||
class RimSummaryCase;
|
||||
@@ -59,21 +58,3 @@ protected:
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimSummaryPlotCollection_newSummaryPlot : public caf::PdmObjectMethod
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimSummaryPlotCollection_newSummaryPlot( caf::PdmObjectHandle* self );
|
||||
|
||||
caf::PdmObjectHandle* execute();
|
||||
bool deleteObjectAfterReply() const override;
|
||||
|
||||
private:
|
||||
caf::PdmPtrArrayField<RimSummaryCase*> m_summaryCases;
|
||||
caf::PdmPtrArrayField<RimSummaryCaseCollection*> m_ensembles;
|
||||
};
|
||||
|
||||
@@ -347,14 +347,7 @@ void RicSummaryPlotFeatureImpl::createSummaryPlotsFromArgumentLine( const QStrin
|
||||
bool isNormalizedY = options.contains( "-n" );
|
||||
bool isSinglePlot = options.contains( "-s" );
|
||||
|
||||
enum EnsembleColoringType
|
||||
{
|
||||
SINGLE_COLOR,
|
||||
PARAMETER,
|
||||
LOG_PARAMETER,
|
||||
NONE
|
||||
};
|
||||
EnsembleColoringType ensembleColoringStyle = NONE;
|
||||
EnsembleColoringType ensembleColoringStyle = EnsembleColoringType::NONE;
|
||||
{
|
||||
int e_pos = options.lastIndexOf( "-e" );
|
||||
int c_pos = options.lastIndexOf( "-c" );
|
||||
@@ -364,21 +357,21 @@ void RicSummaryPlotFeatureImpl::createSummaryPlotsFromArgumentLine( const QStrin
|
||||
if ( e_pos > lastEnsembleOptionPos )
|
||||
{
|
||||
lastEnsembleOptionPos = e_pos;
|
||||
ensembleColoringStyle = SINGLE_COLOR;
|
||||
ensembleColoringStyle = EnsembleColoringType::SINGLE_COLOR;
|
||||
}
|
||||
if ( c_pos > lastEnsembleOptionPos )
|
||||
{
|
||||
lastEnsembleOptionPos = c_pos;
|
||||
ensembleColoringStyle = PARAMETER;
|
||||
ensembleColoringStyle = EnsembleColoringType::PARAMETER;
|
||||
}
|
||||
if ( cl_pos > lastEnsembleOptionPos )
|
||||
{
|
||||
lastEnsembleOptionPos = cl_pos;
|
||||
ensembleColoringStyle = LOG_PARAMETER;
|
||||
ensembleColoringStyle = EnsembleColoringType::LOG_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
bool isEnsembleMode = ensembleColoringStyle != NONE;
|
||||
bool isEnsembleMode = ensembleColoringStyle != EnsembleColoringType::NONE;
|
||||
|
||||
std::vector<RimSummaryCase*> summaryCasesToUse;
|
||||
|
||||
@@ -419,129 +412,38 @@ void RicSummaryPlotFeatureImpl::createSummaryPlotsFromArgumentLine( const QStrin
|
||||
|
||||
if ( isSinglePlot )
|
||||
{
|
||||
RimSummaryPlot* newPlot = sumPlotColl->createSummaryPlotWithAutoTitle();
|
||||
|
||||
if ( isEnsembleMode )
|
||||
{
|
||||
std::set<RifEclipseSummaryAddress> filteredAdressesFromCases =
|
||||
applySummaryAddressFiltersToCases( summaryCasesToUse, summaryAddressFilters );
|
||||
|
||||
for ( const auto& addr : filteredAdressesFromCases )
|
||||
{
|
||||
RimEnsembleCurveSet* curveSet = new RimEnsembleCurveSet();
|
||||
curveSet->setSummaryCaseCollection( ensemble );
|
||||
curveSet->setSummaryAddress( addr );
|
||||
|
||||
if ( ensembleColoringStyle == PARAMETER || ensembleColoringStyle == LOG_PARAMETER )
|
||||
{
|
||||
curveSet->setColorMode( RimEnsembleCurveSet::ColorMode::BY_ENSEMBLE_PARAM );
|
||||
curveSet->setEnsembleParameter( ensembleColoringParameter );
|
||||
|
||||
if ( ensembleColoringStyle == LOG_PARAMETER )
|
||||
{
|
||||
curveSet->legendConfig()->setMappingMode( RimRegularLegendConfig::LOG10_CONTINUOUS );
|
||||
}
|
||||
}
|
||||
|
||||
newPlot->ensembleCurveSetCollection()->addCurveSet( curveSet );
|
||||
|
||||
if ( addHistoryCurves )
|
||||
{
|
||||
RimSummaryCurve* historyCurve = createHistoryCurve( addr, summaryCasesToUse[0] );
|
||||
|
||||
if ( historyCurve ) newPlot->addCurveNoUpdate( historyCurve );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( RimSummaryCase* sumCase : summaryCasesToUse )
|
||||
{
|
||||
RicSummaryPlotFeatureImpl::addCurvesFromAddressFiltersToPlot( summaryAddressFilters,
|
||||
newPlot,
|
||||
sumCase,
|
||||
addHistoryCurves );
|
||||
addHistoryCurves = false;
|
||||
}
|
||||
}
|
||||
RimSummaryPlot* newPlot = createSummaryPlotFromAddresses( sumPlotColl,
|
||||
summaryCasesToUse,
|
||||
ensemble,
|
||||
summaryAddressFilters,
|
||||
addHistoryCurves,
|
||||
ensembleColoringStyle,
|
||||
ensembleColoringParameter );
|
||||
|
||||
lastPlotCreated = newPlot;
|
||||
|
||||
newPlot->setLegendsVisible( !hideLegend );
|
||||
newPlot->setNormalizationEnabled( isNormalizedY );
|
||||
|
||||
newPlot->applyDefaultCurveAppearances();
|
||||
newPlot->loadDataAndUpdate();
|
||||
}
|
||||
else // Multiplot, one for each separate summary address
|
||||
{
|
||||
std::set<RifEclipseSummaryAddress> filteredAdressesFromCases =
|
||||
applySummaryAddressFiltersToCases( summaryCasesToUse, summaryAddressFilters );
|
||||
std::vector<RimSummaryPlot*> summaryPlots =
|
||||
createMultipleSummaryPlotsFromAddresses( sumPlotColl,
|
||||
summaryCasesToUse,
|
||||
ensemble,
|
||||
summaryAddressFilters,
|
||||
addHistoryCurves,
|
||||
ensembleColoringStyle,
|
||||
ensembleColoringParameter );
|
||||
|
||||
for ( const auto& addr : filteredAdressesFromCases )
|
||||
lastPlotCreated = summaryPlots.back();
|
||||
|
||||
for ( auto summaryPlot : summaryPlots )
|
||||
{
|
||||
std::vector<RimSummaryCurve*> createdCurves;
|
||||
std::vector<RimEnsembleCurveSet*> createdEnsembleCurveSets;
|
||||
if ( isEnsembleMode )
|
||||
{
|
||||
RimEnsembleCurveSet* curveSet = new RimEnsembleCurveSet();
|
||||
|
||||
curveSet->setSummaryCaseCollection( ensemble );
|
||||
curveSet->setSummaryAddress( addr );
|
||||
if ( ensembleColoringStyle == PARAMETER || ensembleColoringStyle == LOG_PARAMETER )
|
||||
{
|
||||
curveSet->setColorMode( RimEnsembleCurveSet::ColorMode::BY_ENSEMBLE_PARAM );
|
||||
curveSet->setEnsembleParameter( ensembleColoringParameter );
|
||||
if ( ensembleColoringStyle == LOG_PARAMETER )
|
||||
{
|
||||
curveSet->legendConfig()->setMappingMode( RimRegularLegendConfig::LOG10_CONTINUOUS );
|
||||
}
|
||||
}
|
||||
createdEnsembleCurveSets.push_back( curveSet );
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( RimSummaryCase* sumCase : summaryCasesToUse )
|
||||
{
|
||||
const std::set<RifEclipseSummaryAddress>& allAddrsInCase =
|
||||
sumCase->summaryReader()->allResultAddresses();
|
||||
if ( allAddrsInCase.count( addr ) )
|
||||
{
|
||||
RimSummaryCurve* newCurve = new RimSummaryCurve();
|
||||
newCurve->setSummaryCaseY( sumCase );
|
||||
newCurve->setSummaryAddressYAndApplyInterpolation( addr );
|
||||
createdCurves.push_back( newCurve );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( addHistoryCurves )
|
||||
{
|
||||
RimSummaryCurve* historyCurve = createHistoryCurve( addr, summaryCasesToUse[0] );
|
||||
if ( historyCurve ) createdCurves.push_back( historyCurve );
|
||||
}
|
||||
|
||||
if ( createdCurves.size() || createdEnsembleCurveSets.size() )
|
||||
{
|
||||
RimSummaryPlot* newPlot = sumPlotColl->createSummaryPlotWithAutoTitle();
|
||||
|
||||
for ( auto curve : createdCurves )
|
||||
{
|
||||
newPlot->addCurveNoUpdate( curve );
|
||||
}
|
||||
|
||||
for ( auto curveSet : createdEnsembleCurveSets )
|
||||
{
|
||||
newPlot->ensembleCurveSetCollection()->addCurveSet( curveSet );
|
||||
}
|
||||
|
||||
newPlot->setLegendsVisible( !hideLegend );
|
||||
newPlot->setNormalizationEnabled( isNormalizedY );
|
||||
|
||||
newPlot->applyDefaultCurveAppearances();
|
||||
newPlot->loadDataAndUpdate();
|
||||
lastPlotCreated = newPlot;
|
||||
}
|
||||
summaryPlot->setLegendsVisible( !hideLegend );
|
||||
summaryPlot->setNormalizationEnabled( isNormalizedY );
|
||||
summaryPlot->loadDataAndUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -689,6 +591,148 @@ void RicSummaryPlotFeatureImpl::createSummaryPlotsFromArgumentLine( const QStrin
|
||||
}
|
||||
}
|
||||
|
||||
RimSummaryPlot*
|
||||
RicSummaryPlotFeatureImpl::createSummaryPlotFromAddresses( RimSummaryPlotCollection* sumPlotColl,
|
||||
const std::vector<RimSummaryCase*>& summaryCasesToUse,
|
||||
RimSummaryCaseCollection* ensemble,
|
||||
QStringList summaryAddressFilters,
|
||||
bool addHistoryCurves,
|
||||
EnsembleColoringType ensembleColoringStyle,
|
||||
QString ensembleColoringParameter )
|
||||
{
|
||||
RimSummaryPlot* newPlot = sumPlotColl->createSummaryPlotWithAutoTitle();
|
||||
|
||||
if ( ensemble )
|
||||
{
|
||||
std::set<RifEclipseSummaryAddress> filteredAdressesFromCases =
|
||||
applySummaryAddressFiltersToCases( summaryCasesToUse, summaryAddressFilters );
|
||||
|
||||
for ( const auto& addr : filteredAdressesFromCases )
|
||||
{
|
||||
RimEnsembleCurveSet* curveSet = new RimEnsembleCurveSet();
|
||||
curveSet->setSummaryCaseCollection( ensemble );
|
||||
curveSet->setSummaryAddress( addr );
|
||||
|
||||
if ( ensembleColoringStyle == EnsembleColoringType::PARAMETER ||
|
||||
ensembleColoringStyle == EnsembleColoringType::LOG_PARAMETER )
|
||||
{
|
||||
curveSet->setColorMode( RimEnsembleCurveSet::ColorMode::BY_ENSEMBLE_PARAM );
|
||||
curveSet->setEnsembleParameter( ensembleColoringParameter );
|
||||
|
||||
if ( ensembleColoringStyle == EnsembleColoringType::LOG_PARAMETER )
|
||||
{
|
||||
curveSet->legendConfig()->setMappingMode( RimRegularLegendConfig::LOG10_CONTINUOUS );
|
||||
}
|
||||
}
|
||||
|
||||
newPlot->ensembleCurveSetCollection()->addCurveSet( curveSet );
|
||||
|
||||
if ( addHistoryCurves )
|
||||
{
|
||||
RimSummaryCurve* historyCurve = createHistoryCurve( addr, summaryCasesToUse[0] );
|
||||
|
||||
if ( historyCurve ) newPlot->addCurveNoUpdate( historyCurve );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( RimSummaryCase* sumCase : summaryCasesToUse )
|
||||
{
|
||||
RicSummaryPlotFeatureImpl::addCurvesFromAddressFiltersToPlot( summaryAddressFilters,
|
||||
newPlot,
|
||||
sumCase,
|
||||
addHistoryCurves );
|
||||
addHistoryCurves = false;
|
||||
}
|
||||
}
|
||||
|
||||
newPlot->applyDefaultCurveAppearances();
|
||||
|
||||
return newPlot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimSummaryPlot*> RicSummaryPlotFeatureImpl::createMultipleSummaryPlotsFromAddresses(
|
||||
RimSummaryPlotCollection* sumPlotColl,
|
||||
const std::vector<RimSummaryCase*>& summaryCasesToUse,
|
||||
RimSummaryCaseCollection* ensemble,
|
||||
QStringList summaryAddressFilters,
|
||||
bool addHistoryCurves,
|
||||
EnsembleColoringType ensembleColoringStyle /*= EnsembleColoringType::NONE*/,
|
||||
QString ensembleColoringParameter /*= "" */ )
|
||||
{
|
||||
std::vector<RimSummaryPlot*> newSummaryPlots;
|
||||
|
||||
std::set<RifEclipseSummaryAddress> filteredAdressesFromCases =
|
||||
applySummaryAddressFiltersToCases( summaryCasesToUse, summaryAddressFilters );
|
||||
|
||||
for ( const auto& addr : filteredAdressesFromCases )
|
||||
{
|
||||
std::vector<RimSummaryCurve*> createdCurves;
|
||||
std::vector<RimEnsembleCurveSet*> createdEnsembleCurveSets;
|
||||
if ( ensemble )
|
||||
{
|
||||
RimEnsembleCurveSet* curveSet = new RimEnsembleCurveSet();
|
||||
|
||||
curveSet->setSummaryCaseCollection( ensemble );
|
||||
curveSet->setSummaryAddress( addr );
|
||||
if ( ensembleColoringStyle == EnsembleColoringType::PARAMETER ||
|
||||
ensembleColoringStyle == EnsembleColoringType::LOG_PARAMETER )
|
||||
{
|
||||
curveSet->setColorMode( RimEnsembleCurveSet::ColorMode::BY_ENSEMBLE_PARAM );
|
||||
curveSet->setEnsembleParameter( ensembleColoringParameter );
|
||||
if ( ensembleColoringStyle == EnsembleColoringType::LOG_PARAMETER )
|
||||
{
|
||||
curveSet->legendConfig()->setMappingMode( RimRegularLegendConfig::LOG10_CONTINUOUS );
|
||||
}
|
||||
}
|
||||
createdEnsembleCurveSets.push_back( curveSet );
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( RimSummaryCase* sumCase : summaryCasesToUse )
|
||||
{
|
||||
const std::set<RifEclipseSummaryAddress>& allAddrsInCase = sumCase->summaryReader()->allResultAddresses();
|
||||
if ( allAddrsInCase.count( addr ) )
|
||||
{
|
||||
RimSummaryCurve* newCurve = new RimSummaryCurve();
|
||||
newCurve->setSummaryCaseY( sumCase );
|
||||
newCurve->setSummaryAddressYAndApplyInterpolation( addr );
|
||||
createdCurves.push_back( newCurve );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( addHistoryCurves )
|
||||
{
|
||||
RimSummaryCurve* historyCurve = createHistoryCurve( addr, summaryCasesToUse[0] );
|
||||
if ( historyCurve ) createdCurves.push_back( historyCurve );
|
||||
}
|
||||
|
||||
if ( createdCurves.size() || createdEnsembleCurveSets.size() )
|
||||
{
|
||||
RimSummaryPlot* newPlot = sumPlotColl->createSummaryPlotWithAutoTitle();
|
||||
|
||||
for ( auto curve : createdCurves )
|
||||
{
|
||||
newPlot->addCurveNoUpdate( curve );
|
||||
}
|
||||
|
||||
for ( auto curveSet : createdEnsembleCurveSets )
|
||||
{
|
||||
newPlot->ensembleCurveSetCollection()->addCurveSet( curveSet );
|
||||
}
|
||||
|
||||
newPlot->applyDefaultCurveAppearances();
|
||||
newSummaryPlots.push_back( newPlot );
|
||||
}
|
||||
}
|
||||
return newSummaryPlots;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
#include "RifEclipseSummaryAddress.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
@@ -30,6 +32,7 @@ class PdmObject;
|
||||
class RimSummaryCurve;
|
||||
class RimSummaryPlot;
|
||||
class RimSummaryCase;
|
||||
class RimSummaryCaseCollection;
|
||||
class RimSummaryPlotCollection;
|
||||
|
||||
class QStringList;
|
||||
@@ -37,6 +40,14 @@ class QStringList;
|
||||
class RicSummaryPlotFeatureImpl
|
||||
{
|
||||
public:
|
||||
enum class EnsembleColoringType
|
||||
{
|
||||
SINGLE_COLOR,
|
||||
PARAMETER,
|
||||
LOG_PARAMETER,
|
||||
NONE
|
||||
};
|
||||
|
||||
static RimSummaryCurve* addDefaultCurveToPlot( RimSummaryPlot* plot, RimSummaryCase* summaryCase );
|
||||
static std::vector<RimSummaryCurve*> addDefaultCurvesToPlot( RimSummaryPlot* plot, RimSummaryCase* summaryCase );
|
||||
static void ensureAtLeastOnePlot( RimSummaryPlotCollection* summaryPlotCollection, RimSummaryCase* summaryCase );
|
||||
@@ -44,6 +55,24 @@ public:
|
||||
|
||||
static void createSummaryPlotsFromArgumentLine( const QStringList& arguments );
|
||||
|
||||
static RimSummaryPlot*
|
||||
createSummaryPlotFromAddresses( RimSummaryPlotCollection* sumPlotColl,
|
||||
const std::vector<RimSummaryCase*>& summaryCasesToUse,
|
||||
RimSummaryCaseCollection* ensemble,
|
||||
QStringList summaryAddressFilters,
|
||||
bool addHistoryCurves = false,
|
||||
EnsembleColoringType ensembleColoringStyle = EnsembleColoringType::NONE,
|
||||
QString ensembleColoringParameter = "" );
|
||||
|
||||
static std::vector<RimSummaryPlot*>
|
||||
createMultipleSummaryPlotsFromAddresses( RimSummaryPlotCollection* sumPlotColl,
|
||||
const std::vector<RimSummaryCase*>& summaryCasesToUse,
|
||||
RimSummaryCaseCollection* ensemble,
|
||||
QStringList summaryAddressFilters,
|
||||
bool addHistoryCurves = false,
|
||||
EnsembleColoringType ensembleColoringStyle = EnsembleColoringType::NONE,
|
||||
QString ensembleColoringParameter = "" );
|
||||
|
||||
static void filteredSummaryAdressesFromCase( const QStringList& curveFilters,
|
||||
const std::set<RifEclipseSummaryAddress>& allAddressesInCase,
|
||||
std::set<RifEclipseSummaryAddress>* setToInsertFilteredAddressesIn,
|
||||
|
||||
Reference in New Issue
Block a user