mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4828 Summary Plot Templates : Support ensembles as plot data sources
This commit is contained in:
parent
3d3ad421dd
commit
2c73b2ed02
@ -40,7 +40,10 @@ CAF_CMD_SOURCE_INIT( RicCreatePlotFromSelectionFeature, "RicCreatePlotFromSelect
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicCreatePlotFromSelectionFeature::isCommandEnabled()
|
||||
{
|
||||
return !selectedSummaryCases().empty();
|
||||
bool anySummaryCases = !RicSummaryPlotTemplateTools::selectedSummaryCases().empty();
|
||||
bool anySummaryCaseCollections = !RicSummaryPlotTemplateTools::selectedSummaryCaseCollections().empty();
|
||||
|
||||
return ( anySummaryCases || anySummaryCaseCollections );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -48,11 +51,12 @@ bool RicCreatePlotFromSelectionFeature::isCommandEnabled()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCreatePlotFromSelectionFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
QString fileName = RicSummaryPlotTemplateTools::selectPlotTemplatePath();
|
||||
std::vector<RimSummaryCase*> sumCases = selectedSummaryCases();
|
||||
QString fileName = RicSummaryPlotTemplateTools::selectPlotTemplatePath();
|
||||
auto sumCases = RicSummaryPlotTemplateTools::selectedSummaryCases();
|
||||
auto sumCaseCollections = RicSummaryPlotTemplateTools::selectedSummaryCaseCollections();
|
||||
|
||||
RimSummaryPlot* newSummaryPlot = RicSummaryPlotTemplateTools::createPlotFromTemplateFile( fileName );
|
||||
RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( newSummaryPlot, sumCases );
|
||||
RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( newSummaryPlot, sumCases, sumCaseCollections );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -63,14 +67,3 @@ void RicCreatePlotFromSelectionFeature::setupActionLook( QAction* actionToSetup
|
||||
actionToSetup->setText( "Create Plot from Template" );
|
||||
actionToSetup->setIcon( QIcon( ":/SummaryTemplate16x16.png" ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimSummaryCase*> RicCreatePlotFromSelectionFeature::selectedSummaryCases() const
|
||||
{
|
||||
std::vector<RimSummaryCase*> objects;
|
||||
caf::SelectionManager::instance()->objectsByType( &objects );
|
||||
|
||||
return objects;
|
||||
}
|
||||
|
@ -33,7 +33,4 @@ protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
private:
|
||||
std::vector<RimSummaryCase*> selectedSummaryCases() const;
|
||||
};
|
||||
|
@ -40,7 +40,10 @@ CAF_CMD_SOURCE_INIT( RicCreatePlotFromTemplateByShortcutFeature, "RicCreatePlotF
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicCreatePlotFromTemplateByShortcutFeature::isCommandEnabled()
|
||||
{
|
||||
return !selectedSummaryCases().empty();
|
||||
bool anySummaryCases = !RicSummaryPlotTemplateTools::selectedSummaryCases().empty();
|
||||
bool anySummaryCaseCollections = !RicSummaryPlotTemplateTools::selectedSummaryCaseCollections().empty();
|
||||
|
||||
return ( anySummaryCases || anySummaryCaseCollections );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -68,10 +71,11 @@ void RicCreatePlotFromTemplateByShortcutFeature::onActionTriggered( bool isCheck
|
||||
RiaApplication::instance()->preferences()->setDefaultPlotTemplatePath( fileName );
|
||||
}
|
||||
|
||||
std::vector<RimSummaryCase*> sumCases = selectedSummaryCases();
|
||||
auto sumCases = RicSummaryPlotTemplateTools::selectedSummaryCases();
|
||||
auto sumCaseCollections = RicSummaryPlotTemplateTools::selectedSummaryCaseCollections();
|
||||
|
||||
RimSummaryPlot* newSummaryPlot = RicSummaryPlotTemplateTools::createPlotFromTemplateFile( fileName );
|
||||
RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( newSummaryPlot, sumCases );
|
||||
RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( newSummaryPlot, sumCases, sumCaseCollections );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include "RicSummaryPlotTemplateTools.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryCaseCollection.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
@ -32,7 +33,10 @@ CAF_CMD_SOURCE_INIT( RicCreatePlotFromTemplateFeature, "RicCreatePlotFromTemplat
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicCreatePlotFromTemplateFeature::isCommandEnabled()
|
||||
{
|
||||
return !selectedSummaryCases().empty();
|
||||
bool anySummaryCases = !RicSummaryPlotTemplateTools::selectedSummaryCases().empty();
|
||||
bool anySummaryCaseCollections = !RicSummaryPlotTemplateTools::selectedSummaryCaseCollections().empty();
|
||||
|
||||
return ( anySummaryCases || anySummaryCaseCollections );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -40,11 +44,13 @@ bool RicCreatePlotFromTemplateFeature::isCommandEnabled()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCreatePlotFromTemplateFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
QString fileName = userData().toString();
|
||||
std::vector<RimSummaryCase*> sumCases = selectedSummaryCases();
|
||||
QString fileName = userData().toString();
|
||||
auto sumCases = RicSummaryPlotTemplateTools::selectedSummaryCases();
|
||||
auto sumCaseCollections = RicSummaryPlotTemplateTools::selectedSummaryCaseCollections();
|
||||
|
||||
RimSummaryPlot* newSummaryPlot = RicSummaryPlotTemplateTools::createPlotFromTemplateFile( fileName );
|
||||
RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( newSummaryPlot, sumCases );
|
||||
|
||||
RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( newSummaryPlot, sumCases, sumCaseCollections );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -55,14 +61,3 @@ void RicCreatePlotFromTemplateFeature::setupActionLook( QAction* actionToSetup )
|
||||
actionToSetup->setText( "Create Plot from Template" );
|
||||
actionToSetup->setIcon( QIcon( ":/SummaryTemplate16x16.png" ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimSummaryCase*> RicCreatePlotFromTemplateFeature::selectedSummaryCases() const
|
||||
{
|
||||
std::vector<RimSummaryCase*> objects;
|
||||
caf::SelectionManager::instance()->objectsByType( &objects );
|
||||
|
||||
return objects;
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <vector>
|
||||
|
||||
class RimSummaryCase;
|
||||
class RimSummaryCaseCollection;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -35,7 +36,4 @@ protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
private:
|
||||
std::vector<RimSummaryCase*> selectedSummaryCases() const;
|
||||
};
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "RiaPreferences.h"
|
||||
#include "RiaSummaryTools.h"
|
||||
|
||||
#include "RimEnsembleCurveSet.h"
|
||||
#include "RimEnsembleCurveSetCollection.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryCurve.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
@ -140,24 +142,48 @@ QString RicSavePlotTemplateFeature::createTextFromObject( RimSummaryPlot* summar
|
||||
RimSummaryPlot* newSummaryPlot = dynamic_cast<RimSummaryPlot*>( obj );
|
||||
if ( newSummaryPlot )
|
||||
{
|
||||
std::set<QString> caseReferenceStrings;
|
||||
|
||||
for ( const auto& curve : newSummaryPlot->summaryCurves() )
|
||||
{
|
||||
auto fieldHandle = curve->findField( "SummaryCase" );
|
||||
if ( fieldHandle )
|
||||
std::set<QString> caseReferenceStrings;
|
||||
|
||||
for ( const auto& curve : newSummaryPlot->summaryCurves() )
|
||||
{
|
||||
auto reference = fieldHandle->xmlCapability()->referenceString();
|
||||
caseReferenceStrings.insert( reference );
|
||||
auto fieldHandle = curve->findField( "SummaryCase" );
|
||||
if ( fieldHandle )
|
||||
{
|
||||
auto reference = fieldHandle->xmlCapability()->referenceString();
|
||||
caseReferenceStrings.insert( reference );
|
||||
}
|
||||
}
|
||||
|
||||
size_t index = 0;
|
||||
for ( const auto& s : caseReferenceStrings )
|
||||
{
|
||||
QString caseName = QString( "CASE_NAME %1" ).arg( index++ );
|
||||
|
||||
objectAsText.replace( s, caseName );
|
||||
}
|
||||
}
|
||||
|
||||
size_t index = 0;
|
||||
for ( const auto& s : caseReferenceStrings )
|
||||
{
|
||||
QString caseName = QString( "CASE_NAME %1" ).arg( index++ );
|
||||
std::set<QString> ensembleReferenceStrings;
|
||||
|
||||
objectAsText.replace( s, caseName );
|
||||
for ( const auto& curveSet : newSummaryPlot->ensembleCurveSetCollection()->curveSets() )
|
||||
{
|
||||
auto fieldHandle = curveSet->findField( "SummaryGroup" );
|
||||
if ( fieldHandle )
|
||||
{
|
||||
auto reference = fieldHandle->xmlCapability()->referenceString();
|
||||
ensembleReferenceStrings.insert( reference );
|
||||
}
|
||||
}
|
||||
|
||||
size_t index = 0;
|
||||
for ( const auto& s : ensembleReferenceStrings )
|
||||
{
|
||||
QString ensembleName = QString( "ENSEMBLE_NAME %1" ).arg( index++ );
|
||||
|
||||
objectAsText.replace( s, ensembleName );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,8 @@
|
||||
|
||||
#include "PlotTemplates/RimPlotTemplateFileItem.h"
|
||||
#include "RimDialogData.h"
|
||||
#include "RimEnsembleCurveSet.h"
|
||||
#include "RimEnsembleCurveSetCollection.h"
|
||||
#include "RimMainPlotCollection.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryCase.h"
|
||||
@ -40,6 +42,7 @@
|
||||
|
||||
#include "cafPdmUiPropertyViewDialog.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
#include <QFile>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -76,7 +79,9 @@ RimSummaryPlot* RicSummaryPlotTemplateTools::createPlotFromTemplateFile( const Q
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection(
|
||||
RimSummaryPlot* summaryPlot, const std::vector<RimSummaryCase*>& selectedSummaryCases )
|
||||
RimSummaryPlot* summaryPlot,
|
||||
const std::vector<RimSummaryCase*>& selectedSummaryCases,
|
||||
const std::vector<RimSummaryCaseCollection*>& selectedEnsembles )
|
||||
{
|
||||
if ( summaryPlot )
|
||||
{
|
||||
@ -87,38 +92,40 @@ void RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection(
|
||||
summaryPlot->resolveReferencesRecursively();
|
||||
summaryPlot->initAfterReadRecursively();
|
||||
|
||||
auto summaryCurves = summaryPlot->summaryCurves();
|
||||
|
||||
for ( const auto& curve : summaryCurves )
|
||||
{
|
||||
auto fieldHandle = curve->findField( "SummaryCase" );
|
||||
if ( fieldHandle )
|
||||
auto summaryCurves = summaryPlot->summaryCurves();
|
||||
|
||||
for ( const auto& curve : summaryCurves )
|
||||
{
|
||||
auto referenceString = fieldHandle->xmlCapability()->referenceString();
|
||||
auto stringList = referenceString.split( " " );
|
||||
if ( stringList.size() == 2 )
|
||||
auto fieldHandle = curve->findField( "SummaryCase" );
|
||||
if ( fieldHandle )
|
||||
{
|
||||
QString indexAsString = stringList[1];
|
||||
|
||||
bool conversionOk = false;
|
||||
auto index = indexAsString.toUInt( &conversionOk );
|
||||
|
||||
if ( conversionOk && index < selectedSummaryCases.size() )
|
||||
auto referenceString = fieldHandle->xmlCapability()->referenceString();
|
||||
auto stringList = referenceString.split( " " );
|
||||
if ( stringList.size() == 2 )
|
||||
{
|
||||
auto summaryCaseY = selectedSummaryCases[index];
|
||||
curve->setSummaryCaseY( summaryCaseY );
|
||||
QString indexAsString = stringList[1];
|
||||
|
||||
auto currentAddressY = curve->summaryAddressY();
|
||||
if ( summaryCaseY->summaryReader() &&
|
||||
!summaryCaseY->summaryReader()->hasAddress( currentAddressY ) )
|
||||
bool conversionOk = false;
|
||||
auto index = indexAsString.toUInt( &conversionOk );
|
||||
|
||||
if ( conversionOk && index < selectedSummaryCases.size() )
|
||||
{
|
||||
auto allAddresses = summaryCaseY->summaryReader()->allResultAddresses();
|
||||
auto summaryCaseY = selectedSummaryCases[index];
|
||||
curve->setSummaryCaseY( summaryCaseY );
|
||||
|
||||
auto candidate = RicSummaryPlotTemplateTools::firstAddressByQuantity( currentAddressY,
|
||||
allAddresses );
|
||||
if ( candidate.category() != RifEclipseSummaryAddress::SUMMARY_INVALID )
|
||||
auto currentAddressY = curve->summaryAddressY();
|
||||
if ( summaryCaseY->summaryReader() &&
|
||||
!summaryCaseY->summaryReader()->hasAddress( currentAddressY ) )
|
||||
{
|
||||
curve->setSummaryAddressY( candidate );
|
||||
auto allAddresses = summaryCaseY->summaryReader()->allResultAddresses();
|
||||
|
||||
auto candidate = RicSummaryPlotTemplateTools::firstAddressByQuantity( currentAddressY,
|
||||
allAddresses );
|
||||
if ( candidate.category() != RifEclipseSummaryAddress::SUMMARY_INVALID )
|
||||
{
|
||||
curve->setSummaryAddressY( candidate );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -126,6 +133,33 @@ void RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection(
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
auto summaryCurves = summaryPlot->ensembleCurveSetCollection()->curveSets();
|
||||
|
||||
for ( const auto& curveSet : summaryCurves )
|
||||
{
|
||||
auto fieldHandle = curveSet->findField( "SummaryGroup" );
|
||||
if ( fieldHandle )
|
||||
{
|
||||
auto referenceString = fieldHandle->xmlCapability()->referenceString();
|
||||
auto stringList = referenceString.split( " " );
|
||||
if ( stringList.size() == 2 )
|
||||
{
|
||||
QString indexAsString = stringList[1];
|
||||
|
||||
bool conversionOk = false;
|
||||
auto index = indexAsString.toUInt( &conversionOk );
|
||||
|
||||
if ( conversionOk && index < selectedEnsembles.size() )
|
||||
{
|
||||
auto summaryCaseY = selectedEnsembles[index];
|
||||
curveSet->setSummaryCaseCollection( summaryCaseY );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Create additional curves in selected case count is larger than template count
|
||||
|
||||
plotColl->updateConnectedEditors();
|
||||
@ -255,6 +289,28 @@ QString RicSummaryPlotTemplateTools::selectPlotTemplatePath()
|
||||
return QString();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimSummaryCase*> RicSummaryPlotTemplateTools::selectedSummaryCases()
|
||||
{
|
||||
std::vector<RimSummaryCase*> objects;
|
||||
caf::SelectionManager::instance()->objectsByType( &objects );
|
||||
|
||||
return objects;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimSummaryCaseCollection*> RicSummaryPlotTemplateTools::selectedSummaryCaseCollections()
|
||||
{
|
||||
std::vector<RimSummaryCaseCollection*> objects;
|
||||
caf::SelectionManager::instance()->objectsByType( &objects );
|
||||
|
||||
return objects;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -30,6 +30,7 @@ class PdmObject;
|
||||
|
||||
class RimSummaryPlot;
|
||||
class RimSummaryCase;
|
||||
class RimSummaryCaseCollection;
|
||||
class RifEclipseSummaryAddress;
|
||||
|
||||
//==================================================================================================
|
||||
@ -39,8 +40,9 @@ class RicSummaryPlotTemplateTools
|
||||
{
|
||||
public:
|
||||
static RimSummaryPlot* createPlotFromTemplateFile( const QString& fileName );
|
||||
static void appendSummaryPlotToPlotCollection( RimSummaryPlot* summaryPlot,
|
||||
const std::vector<RimSummaryCase*>& selectedSummaryCases );
|
||||
static void appendSummaryPlotToPlotCollection( RimSummaryPlot* summaryPlot,
|
||||
const std::vector<RimSummaryCase*>& selectedSummaryCases,
|
||||
const std::vector<RimSummaryCaseCollection*>& selectedEnsembles );
|
||||
|
||||
static QString htmlTextFromPlotAndSelection( const RimSummaryPlot* templatePlot,
|
||||
const std::set<RifEclipseSummaryAddress>& selectedSummaryAddresses,
|
||||
@ -50,6 +52,9 @@ public:
|
||||
|
||||
static QString selectPlotTemplatePath();
|
||||
|
||||
static std::vector<RimSummaryCase*> selectedSummaryCases();
|
||||
static std::vector<RimSummaryCaseCollection*> selectedSummaryCaseCollections();
|
||||
|
||||
private:
|
||||
static RifEclipseSummaryAddress firstAddressByQuantity( const RifEclipseSummaryAddress& sourceAddress,
|
||||
const std::set<RifEclipseSummaryAddress>& allAddresses );
|
||||
|
@ -845,7 +845,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
menuBuilder << "RicCutReferencesToClipboardFeature";
|
||||
|
||||
menuBuilder << "Separator";
|
||||
if ( dynamic_cast<RimSummaryCase*>( uiItem ) )
|
||||
if ( dynamic_cast<RimSummaryCase*>( uiItem ) || dynamic_cast<RimSummaryCaseCollection*>( uiItem ) )
|
||||
{
|
||||
menuBuilder << "RicCreatePlotFromSelectionFeature";
|
||||
menuBuilder << "RicCreatePlotFromTemplateByShortcutFeature";
|
||||
|
Loading…
Reference in New Issue
Block a user