mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Ensemble plot templates (#4829)
* #4828 Summary Plot Templates : Support ensembles as plot data sources Guard null pointer access and use regexp to match case and index
This commit is contained in:
commit
06b007effb
@ -40,7 +40,10 @@ CAF_CMD_SOURCE_INIT( RicCreatePlotFromSelectionFeature, "RicCreatePlotFromSelect
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
bool RicCreatePlotFromSelectionFeature::isCommandEnabled()
|
bool RicCreatePlotFromSelectionFeature::isCommandEnabled()
|
||||||
{
|
{
|
||||||
return !selectedSummaryCases().empty();
|
bool anySummaryCases = !RicSummaryPlotTemplateTools::selectedSummaryCases().empty();
|
||||||
|
bool anySummaryCaseCollections = !RicSummaryPlotTemplateTools::selectedSummaryCaseCollections().empty();
|
||||||
|
|
||||||
|
return ( anySummaryCases || anySummaryCaseCollections );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -49,10 +52,11 @@ bool RicCreatePlotFromSelectionFeature::isCommandEnabled()
|
|||||||
void RicCreatePlotFromSelectionFeature::onActionTriggered( bool isChecked )
|
void RicCreatePlotFromSelectionFeature::onActionTriggered( bool isChecked )
|
||||||
{
|
{
|
||||||
QString fileName = RicSummaryPlotTemplateTools::selectPlotTemplatePath();
|
QString fileName = RicSummaryPlotTemplateTools::selectPlotTemplatePath();
|
||||||
std::vector<RimSummaryCase*> sumCases = selectedSummaryCases();
|
auto sumCases = RicSummaryPlotTemplateTools::selectedSummaryCases();
|
||||||
|
auto sumCaseCollections = RicSummaryPlotTemplateTools::selectedSummaryCaseCollections();
|
||||||
|
|
||||||
RimSummaryPlot* newSummaryPlot = RicSummaryPlotTemplateTools::createPlotFromTemplateFile( fileName );
|
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->setText( "Create Plot from Template" );
|
||||||
actionToSetup->setIcon( QIcon( ":/SummaryTemplate16x16.png" ) );
|
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;
|
bool isCommandEnabled() override;
|
||||||
void onActionTriggered( bool isChecked ) override;
|
void onActionTriggered( bool isChecked ) override;
|
||||||
void setupActionLook( QAction* actionToSetup ) 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()
|
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 );
|
RiaApplication::instance()->preferences()->setDefaultPlotTemplatePath( fileName );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<RimSummaryCase*> sumCases = selectedSummaryCases();
|
auto sumCases = RicSummaryPlotTemplateTools::selectedSummaryCases();
|
||||||
|
auto sumCaseCollections = RicSummaryPlotTemplateTools::selectedSummaryCaseCollections();
|
||||||
|
|
||||||
RimSummaryPlot* newSummaryPlot = RicSummaryPlotTemplateTools::createPlotFromTemplateFile( fileName );
|
RimSummaryPlot* newSummaryPlot = RicSummaryPlotTemplateTools::createPlotFromTemplateFile( fileName );
|
||||||
RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( newSummaryPlot, sumCases );
|
RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection( newSummaryPlot, sumCases, sumCaseCollections );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -85,14 +89,3 @@ void RicCreatePlotFromTemplateByShortcutFeature::setupActionLook( QAction* actio
|
|||||||
QKeySequence keySeq( Qt::CTRL + Qt::Key_T );
|
QKeySequence keySeq( Qt::CTRL + Qt::Key_T );
|
||||||
actionToSetup->setShortcut( keySeq );
|
actionToSetup->setShortcut( keySeq );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
std::vector<RimSummaryCase*> RicCreatePlotFromTemplateByShortcutFeature::selectedSummaryCases() const
|
|
||||||
{
|
|
||||||
std::vector<RimSummaryCase*> objects;
|
|
||||||
caf::SelectionManager::instance()->objectsByType( &objects );
|
|
||||||
|
|
||||||
return objects;
|
|
||||||
}
|
|
||||||
|
@ -35,7 +35,4 @@ protected:
|
|||||||
bool isCommandEnabled() override;
|
bool isCommandEnabled() override;
|
||||||
void onActionTriggered( bool isChecked ) override;
|
void onActionTriggered( bool isChecked ) override;
|
||||||
void setupActionLook( QAction* actionToSetup ) override;
|
void setupActionLook( QAction* actionToSetup ) override;
|
||||||
|
|
||||||
private:
|
|
||||||
std::vector<RimSummaryCase*> selectedSummaryCases() const;
|
|
||||||
};
|
};
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "RicSummaryPlotTemplateTools.h"
|
#include "RicSummaryPlotTemplateTools.h"
|
||||||
#include "RimSummaryCase.h"
|
#include "RimSummaryCase.h"
|
||||||
|
#include "RimSummaryCaseCollection.h"
|
||||||
|
|
||||||
#include "cafSelectionManager.h"
|
#include "cafSelectionManager.h"
|
||||||
|
|
||||||
@ -32,7 +33,10 @@ CAF_CMD_SOURCE_INIT( RicCreatePlotFromTemplateFeature, "RicCreatePlotFromTemplat
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
bool RicCreatePlotFromTemplateFeature::isCommandEnabled()
|
bool RicCreatePlotFromTemplateFeature::isCommandEnabled()
|
||||||
{
|
{
|
||||||
return !selectedSummaryCases().empty();
|
bool anySummaryCases = !RicSummaryPlotTemplateTools::selectedSummaryCases().empty();
|
||||||
|
bool anySummaryCaseCollections = !RicSummaryPlotTemplateTools::selectedSummaryCaseCollections().empty();
|
||||||
|
|
||||||
|
return ( anySummaryCases || anySummaryCaseCollections );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -41,10 +45,12 @@ bool RicCreatePlotFromTemplateFeature::isCommandEnabled()
|
|||||||
void RicCreatePlotFromTemplateFeature::onActionTriggered( bool isChecked )
|
void RicCreatePlotFromTemplateFeature::onActionTriggered( bool isChecked )
|
||||||
{
|
{
|
||||||
QString fileName = userData().toString();
|
QString fileName = userData().toString();
|
||||||
std::vector<RimSummaryCase*> sumCases = selectedSummaryCases();
|
auto sumCases = RicSummaryPlotTemplateTools::selectedSummaryCases();
|
||||||
|
auto sumCaseCollections = RicSummaryPlotTemplateTools::selectedSummaryCaseCollections();
|
||||||
|
|
||||||
RimSummaryPlot* newSummaryPlot = RicSummaryPlotTemplateTools::createPlotFromTemplateFile( fileName );
|
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->setText( "Create Plot from Template" );
|
||||||
actionToSetup->setIcon( QIcon( ":/SummaryTemplate16x16.png" ) );
|
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>
|
#include <vector>
|
||||||
|
|
||||||
class RimSummaryCase;
|
class RimSummaryCase;
|
||||||
|
class RimSummaryCaseCollection;
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
///
|
///
|
||||||
@ -35,7 +36,4 @@ protected:
|
|||||||
bool isCommandEnabled() override;
|
bool isCommandEnabled() override;
|
||||||
void onActionTriggered( bool isChecked ) override;
|
void onActionTriggered( bool isChecked ) override;
|
||||||
void setupActionLook( QAction* actionToSetup ) override;
|
void setupActionLook( QAction* actionToSetup ) override;
|
||||||
|
|
||||||
private:
|
|
||||||
std::vector<RimSummaryCase*> selectedSummaryCases() const;
|
|
||||||
};
|
};
|
||||||
|
@ -19,12 +19,15 @@
|
|||||||
#include "RicSavePlotTemplateFeature.h"
|
#include "RicSavePlotTemplateFeature.h"
|
||||||
|
|
||||||
#include "RicReloadPlotTemplatesFeature.h"
|
#include "RicReloadPlotTemplatesFeature.h"
|
||||||
|
#include "RicSummaryPlotTemplateTools.h"
|
||||||
|
|
||||||
#include "RiaGuiApplication.h"
|
#include "RiaGuiApplication.h"
|
||||||
#include "RiaLogging.h"
|
#include "RiaLogging.h"
|
||||||
#include "RiaPreferences.h"
|
#include "RiaPreferences.h"
|
||||||
#include "RiaSummaryTools.h"
|
#include "RiaSummaryTools.h"
|
||||||
|
|
||||||
|
#include "RimEnsembleCurveSet.h"
|
||||||
|
#include "RimEnsembleCurveSetCollection.h"
|
||||||
#include "RimProject.h"
|
#include "RimProject.h"
|
||||||
#include "RimSummaryCurve.h"
|
#include "RimSummaryCurve.h"
|
||||||
#include "RimSummaryPlot.h"
|
#include "RimSummaryPlot.h"
|
||||||
@ -139,12 +142,14 @@ QString RicSavePlotTemplateFeature::createTextFromObject( RimSummaryPlot* summar
|
|||||||
|
|
||||||
RimSummaryPlot* newSummaryPlot = dynamic_cast<RimSummaryPlot*>( obj );
|
RimSummaryPlot* newSummaryPlot = dynamic_cast<RimSummaryPlot*>( obj );
|
||||||
if ( newSummaryPlot )
|
if ( newSummaryPlot )
|
||||||
|
{
|
||||||
{
|
{
|
||||||
std::set<QString> caseReferenceStrings;
|
std::set<QString> caseReferenceStrings;
|
||||||
|
|
||||||
|
const QString summaryFieldKeyword = RicSummaryPlotTemplateTools::summaryCaseFieldKeyword();
|
||||||
for ( const auto& curve : newSummaryPlot->summaryCurves() )
|
for ( const auto& curve : newSummaryPlot->summaryCurves() )
|
||||||
{
|
{
|
||||||
auto fieldHandle = curve->findField( "SummaryCase" );
|
auto fieldHandle = curve->findField( summaryFieldKeyword );
|
||||||
if ( fieldHandle )
|
if ( fieldHandle )
|
||||||
{
|
{
|
||||||
auto reference = fieldHandle->xmlCapability()->referenceString();
|
auto reference = fieldHandle->xmlCapability()->referenceString();
|
||||||
@ -155,12 +160,39 @@ QString RicSavePlotTemplateFeature::createTextFromObject( RimSummaryPlot* summar
|
|||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
for ( const auto& s : caseReferenceStrings )
|
for ( const auto& s : caseReferenceStrings )
|
||||||
{
|
{
|
||||||
QString caseName = QString( "CASE_NAME %1" ).arg( index++ );
|
QString placeholderText = RicSummaryPlotTemplateTools::placeholderTextForSummaryCase();
|
||||||
|
QString caseName = QString( "%1 %2" ).arg( placeholderText ).arg( index++ );
|
||||||
|
|
||||||
objectAsText.replace( s, caseName );
|
objectAsText.replace( s, caseName );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::set<QString> ensembleReferenceStrings;
|
||||||
|
|
||||||
|
const QString summaryGroupFieldKeyword = RicSummaryPlotTemplateTools::summaryGroupFieldKeyword();
|
||||||
|
|
||||||
|
for ( const auto& curveSet : newSummaryPlot->ensembleCurveSetCollection()->curveSets() )
|
||||||
|
{
|
||||||
|
auto fieldHandle = curveSet->findField( summaryGroupFieldKeyword );
|
||||||
|
if ( fieldHandle )
|
||||||
|
{
|
||||||
|
auto reference = fieldHandle->xmlCapability()->referenceString();
|
||||||
|
ensembleReferenceStrings.insert( reference );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t index = 0;
|
||||||
|
for ( const auto& s : ensembleReferenceStrings )
|
||||||
|
{
|
||||||
|
QString placeholderText = RicSummaryPlotTemplateTools::placeholderTextForSummaryGroup();
|
||||||
|
QString ensembleName = QString( "%1 %2" ).arg( placeholderText ).arg( index++ );
|
||||||
|
|
||||||
|
objectAsText.replace( s, ensembleName );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
delete obj;
|
delete obj;
|
||||||
|
|
||||||
return objectAsText;
|
return objectAsText;
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
|
|
||||||
#include "PlotTemplates/RimPlotTemplateFileItem.h"
|
#include "PlotTemplates/RimPlotTemplateFileItem.h"
|
||||||
#include "RimDialogData.h"
|
#include "RimDialogData.h"
|
||||||
|
#include "RimEnsembleCurveSet.h"
|
||||||
|
#include "RimEnsembleCurveSetCollection.h"
|
||||||
#include "RimMainPlotCollection.h"
|
#include "RimMainPlotCollection.h"
|
||||||
#include "RimProject.h"
|
#include "RimProject.h"
|
||||||
#include "RimSummaryCase.h"
|
#include "RimSummaryCase.h"
|
||||||
@ -39,8 +41,10 @@
|
|||||||
#include "RiuPlotMainWindow.h"
|
#include "RiuPlotMainWindow.h"
|
||||||
|
|
||||||
#include "cafPdmUiPropertyViewDialog.h"
|
#include "cafPdmUiPropertyViewDialog.h"
|
||||||
|
#include "cafSelectionManager.h"
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
@ -76,41 +80,50 @@ RimSummaryPlot* RicSummaryPlotTemplateTools::createPlotFromTemplateFile( const Q
|
|||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection(
|
void RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection(
|
||||||
RimSummaryPlot* summaryPlot, const std::vector<RimSummaryCase*>& selectedSummaryCases )
|
RimSummaryPlot* summaryPlot,
|
||||||
|
const std::vector<RimSummaryCase*>& selectedSummaryCases,
|
||||||
|
const std::vector<RimSummaryCaseCollection*>& selectedEnsembles )
|
||||||
{
|
{
|
||||||
if ( summaryPlot )
|
if ( !summaryPlot ) return;
|
||||||
{
|
|
||||||
RimSummaryPlotCollection* plotColl =
|
if ( selectedSummaryCases.empty() && selectedEnsembles.empty() ) return;
|
||||||
RiaApplication::instance()->project()->mainPlotCollection()->summaryPlotCollection();
|
|
||||||
|
RimSummaryPlotCollection* plotColl = RiaApplication::instance()->project()->mainPlotCollection()->summaryPlotCollection();
|
||||||
|
|
||||||
plotColl->summaryPlots.push_back( summaryPlot );
|
plotColl->summaryPlots.push_back( summaryPlot );
|
||||||
summaryPlot->resolveReferencesRecursively();
|
summaryPlot->resolveReferencesRecursively();
|
||||||
summaryPlot->initAfterReadRecursively();
|
summaryPlot->initAfterReadRecursively();
|
||||||
|
|
||||||
|
{
|
||||||
|
// Replace single summary curves data sources
|
||||||
|
|
||||||
auto summaryCurves = summaryPlot->summaryCurves();
|
auto summaryCurves = summaryPlot->summaryCurves();
|
||||||
|
|
||||||
|
const QString summaryFieldKeyword = RicSummaryPlotTemplateTools::summaryCaseFieldKeyword();
|
||||||
|
|
||||||
|
int maximumIndexValue = -1;
|
||||||
for ( const auto& curve : summaryCurves )
|
for ( const auto& curve : summaryCurves )
|
||||||
{
|
{
|
||||||
auto fieldHandle = curve->findField( "SummaryCase" );
|
auto fieldHandle = curve->findField( summaryFieldKeyword );
|
||||||
if ( fieldHandle )
|
if ( fieldHandle )
|
||||||
{
|
{
|
||||||
auto referenceString = fieldHandle->xmlCapability()->referenceString();
|
|
||||||
auto stringList = referenceString.split( " " );
|
|
||||||
if ( stringList.size() == 2 )
|
|
||||||
{
|
|
||||||
QString indexAsString = stringList[1];
|
|
||||||
|
|
||||||
bool conversionOk = false;
|
bool conversionOk = false;
|
||||||
auto index = indexAsString.toUInt( &conversionOk );
|
const QString placeholderString = RicSummaryPlotTemplateTools::placeholderTextForSummaryCase();
|
||||||
|
|
||||||
if ( conversionOk && index < selectedSummaryCases.size() )
|
auto referenceString = fieldHandle->xmlCapability()->referenceString();
|
||||||
|
int indexValue = RicSummaryPlotTemplateTools::findValueForKeyword( placeholderString,
|
||||||
|
referenceString,
|
||||||
|
&conversionOk );
|
||||||
|
|
||||||
|
maximumIndexValue = std::max( maximumIndexValue, indexValue );
|
||||||
|
|
||||||
|
if ( conversionOk && indexValue >= 0 && indexValue < static_cast<int>( selectedSummaryCases.size() ) )
|
||||||
{
|
{
|
||||||
auto summaryCaseY = selectedSummaryCases[index];
|
auto summaryCaseY = selectedSummaryCases[static_cast<int>( indexValue )];
|
||||||
curve->setSummaryCaseY( summaryCaseY );
|
curve->setSummaryCaseY( summaryCaseY );
|
||||||
|
|
||||||
auto currentAddressY = curve->summaryAddressY();
|
auto currentAddressY = curve->summaryAddressY();
|
||||||
if ( summaryCaseY->summaryReader() &&
|
if ( summaryCaseY->summaryReader() && !summaryCaseY->summaryReader()->hasAddress( currentAddressY ) )
|
||||||
!summaryCaseY->summaryReader()->hasAddress( currentAddressY ) )
|
|
||||||
{
|
{
|
||||||
auto allAddresses = summaryCaseY->summaryReader()->allResultAddresses();
|
auto allAddresses = summaryCaseY->summaryReader()->allResultAddresses();
|
||||||
|
|
||||||
@ -124,14 +137,87 @@ void RicSummaryPlotTemplateTools::appendSummaryPlotToPlotCollection(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( selectedSummaryCases.size() > static_cast<size_t>( maximumIndexValue ) )
|
||||||
|
{
|
||||||
|
// Use the curve style of the last curve in template, and duplicate this for remaining data sources
|
||||||
|
|
||||||
|
if ( !summaryCurves.empty() )
|
||||||
|
{
|
||||||
|
auto lastSummaryCurve = summaryCurves.back();
|
||||||
|
|
||||||
|
for ( size_t i = maximumIndexValue; i < selectedSummaryCases.size(); i++ )
|
||||||
|
{
|
||||||
|
auto newCurve = dynamic_cast<RimSummaryCurve*>(
|
||||||
|
lastSummaryCurve->xmlCapability()->copyByXmlSerialization(
|
||||||
|
caf::PdmDefaultObjectFactory::instance() ) );
|
||||||
|
|
||||||
|
auto summaryCaseY = selectedSummaryCases[i];
|
||||||
|
newCurve->setSummaryCaseY( summaryCaseY );
|
||||||
|
summaryPlot->addCurveAndUpdate( newCurve );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Create additional curves in selected case count is larger than template count
|
{
|
||||||
|
// Replace ensemble data sources
|
||||||
|
|
||||||
|
auto summaryCurveSets = summaryPlot->ensembleCurveSetCollection()->curveSets();
|
||||||
|
|
||||||
|
const QString summaryGroupFieldKeyword = RicSummaryPlotTemplateTools::summaryGroupFieldKeyword();
|
||||||
|
|
||||||
|
int maximumIndexValue = -1;
|
||||||
|
|
||||||
|
for ( const auto& curveSet : summaryCurveSets )
|
||||||
|
{
|
||||||
|
auto fieldHandle = curveSet->findField( summaryGroupFieldKeyword );
|
||||||
|
if ( fieldHandle )
|
||||||
|
{
|
||||||
|
bool conversionOk = false;
|
||||||
|
const QString placeholderString = RicSummaryPlotTemplateTools::placeholderTextForSummaryGroup();
|
||||||
|
|
||||||
|
auto referenceString = fieldHandle->xmlCapability()->referenceString();
|
||||||
|
int indexValue = RicSummaryPlotTemplateTools::findValueForKeyword( placeholderString,
|
||||||
|
referenceString,
|
||||||
|
&conversionOk );
|
||||||
|
|
||||||
|
maximumIndexValue = std::max( maximumIndexValue, indexValue );
|
||||||
|
|
||||||
|
if ( conversionOk && indexValue < static_cast<int>( selectedEnsembles.size() ) )
|
||||||
|
{
|
||||||
|
auto summaryCaseY = selectedEnsembles[indexValue];
|
||||||
|
curveSet->setSummaryCaseCollection( summaryCaseY );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( selectedEnsembles.size() > static_cast<size_t>( maximumIndexValue ) )
|
||||||
|
{
|
||||||
|
// Use the curve style of the last curve in template, and duplicate this for remaining data sources
|
||||||
|
|
||||||
|
if ( !summaryCurveSets.empty() )
|
||||||
|
{
|
||||||
|
auto lastSummaryCurveSet = summaryCurveSets.back();
|
||||||
|
|
||||||
|
for ( size_t i = maximumIndexValue; i < selectedEnsembles.size(); i++ )
|
||||||
|
{
|
||||||
|
auto newCurveSet = dynamic_cast<RimEnsembleCurveSet*>(
|
||||||
|
lastSummaryCurveSet->xmlCapability()->copyByXmlSerialization(
|
||||||
|
caf::PdmDefaultObjectFactory::instance() ) );
|
||||||
|
|
||||||
|
auto ensembleDataSource = selectedEnsembles[i];
|
||||||
|
newCurveSet->setSummaryCaseCollection( ensembleDataSource );
|
||||||
|
|
||||||
|
summaryPlot->ensembleCurveSetCollection()->addCurveSet( newCurveSet );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
plotColl->updateConnectedEditors();
|
plotColl->updateConnectedEditors();
|
||||||
|
|
||||||
summaryPlot->loadDataAndUpdate();
|
summaryPlot->loadDataAndUpdate();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -255,6 +341,60 @@ QString RicSummaryPlotTemplateTools::selectPlotTemplatePath()
|
|||||||
return QString();
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QString RicSummaryPlotTemplateTools::summaryCaseFieldKeyword()
|
||||||
|
{
|
||||||
|
return "SummaryCase";
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QString RicSummaryPlotTemplateTools::summaryGroupFieldKeyword()
|
||||||
|
{
|
||||||
|
return "SummaryGroup";
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QString RicSummaryPlotTemplateTools::placeholderTextForSummaryCase()
|
||||||
|
{
|
||||||
|
return "CASE_NAME";
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QString RicSummaryPlotTemplateTools::placeholderTextForSummaryGroup()
|
||||||
|
{
|
||||||
|
return "ENSEMBLE_NAME";
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -272,3 +412,39 @@ RifEclipseSummaryAddress
|
|||||||
|
|
||||||
return RifEclipseSummaryAddress();
|
return RifEclipseSummaryAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
int RicSummaryPlotTemplateTools::findValueForKeyword( const QString& keyword, const QString& valueString, bool* ok )
|
||||||
|
{
|
||||||
|
// Example string : "CASE_NAME 1"
|
||||||
|
// Will match the string specified by keyword, and return the value captured by the regexp
|
||||||
|
|
||||||
|
QString regexpString = QString( "%1 (\\d++)" ).arg( keyword );
|
||||||
|
QRegularExpression rx( regexpString );
|
||||||
|
|
||||||
|
auto match = rx.match( valueString );
|
||||||
|
if ( match.hasMatch() )
|
||||||
|
{
|
||||||
|
QString integerAsText = match.captured( 1 );
|
||||||
|
|
||||||
|
if ( !integerAsText.isEmpty() )
|
||||||
|
{
|
||||||
|
int integerValue = integerAsText.toInt();
|
||||||
|
|
||||||
|
if ( ok )
|
||||||
|
{
|
||||||
|
*ok = true;
|
||||||
|
}
|
||||||
|
return integerValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ok )
|
||||||
|
{
|
||||||
|
*ok = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
@ -30,6 +30,7 @@ class PdmObject;
|
|||||||
|
|
||||||
class RimSummaryPlot;
|
class RimSummaryPlot;
|
||||||
class RimSummaryCase;
|
class RimSummaryCase;
|
||||||
|
class RimSummaryCaseCollection;
|
||||||
class RifEclipseSummaryAddress;
|
class RifEclipseSummaryAddress;
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
@ -40,7 +41,8 @@ class RicSummaryPlotTemplateTools
|
|||||||
public:
|
public:
|
||||||
static RimSummaryPlot* createPlotFromTemplateFile( const QString& fileName );
|
static RimSummaryPlot* createPlotFromTemplateFile( const QString& fileName );
|
||||||
static void appendSummaryPlotToPlotCollection( RimSummaryPlot* summaryPlot,
|
static void appendSummaryPlotToPlotCollection( RimSummaryPlot* summaryPlot,
|
||||||
const std::vector<RimSummaryCase*>& selectedSummaryCases );
|
const std::vector<RimSummaryCase*>& selectedSummaryCases,
|
||||||
|
const std::vector<RimSummaryCaseCollection*>& selectedEnsembles );
|
||||||
|
|
||||||
static QString htmlTextFromPlotAndSelection( const RimSummaryPlot* templatePlot,
|
static QString htmlTextFromPlotAndSelection( const RimSummaryPlot* templatePlot,
|
||||||
const std::set<RifEclipseSummaryAddress>& selectedSummaryAddresses,
|
const std::set<RifEclipseSummaryAddress>& selectedSummaryAddresses,
|
||||||
@ -50,7 +52,17 @@ public:
|
|||||||
|
|
||||||
static QString selectPlotTemplatePath();
|
static QString selectPlotTemplatePath();
|
||||||
|
|
||||||
|
static std::vector<RimSummaryCase*> selectedSummaryCases();
|
||||||
|
static std::vector<RimSummaryCaseCollection*> selectedSummaryCaseCollections();
|
||||||
|
|
||||||
|
static QString summaryCaseFieldKeyword();
|
||||||
|
static QString summaryGroupFieldKeyword();
|
||||||
|
static QString placeholderTextForSummaryCase();
|
||||||
|
static QString placeholderTextForSummaryGroup();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static RifEclipseSummaryAddress firstAddressByQuantity( const RifEclipseSummaryAddress& sourceAddress,
|
static RifEclipseSummaryAddress firstAddressByQuantity( const RifEclipseSummaryAddress& sourceAddress,
|
||||||
const std::set<RifEclipseSummaryAddress>& allAddresses );
|
const std::set<RifEclipseSummaryAddress>& allAddresses );
|
||||||
|
|
||||||
|
static int findValueForKeyword( const QString& keyword, const QString& valueString, bool* ok );
|
||||||
};
|
};
|
||||||
|
@ -845,7 +845,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
|||||||
menuBuilder << "RicCutReferencesToClipboardFeature";
|
menuBuilder << "RicCutReferencesToClipboardFeature";
|
||||||
|
|
||||||
menuBuilder << "Separator";
|
menuBuilder << "Separator";
|
||||||
if ( dynamic_cast<RimSummaryCase*>( uiItem ) )
|
if ( dynamic_cast<RimSummaryCase*>( uiItem ) || dynamic_cast<RimSummaryCaseCollection*>( uiItem ) )
|
||||||
{
|
{
|
||||||
menuBuilder << "RicCreatePlotFromSelectionFeature";
|
menuBuilder << "RicCreatePlotFromSelectionFeature";
|
||||||
menuBuilder << "RicCreatePlotFromTemplateByShortcutFeature";
|
menuBuilder << "RicCreatePlotFromTemplateByShortcutFeature";
|
||||||
|
@ -614,19 +614,25 @@ std::set<RifEclipseSummaryAddress> RimSummaryPlotSourceStepping::adressesForSour
|
|||||||
{
|
{
|
||||||
auto curveSets = ensembleCollection->curveSetsForSourceStepping();
|
auto curveSets = ensembleCollection->curveSetsForSourceStepping();
|
||||||
for ( const RimEnsembleCurveSet* curveSet : curveSets )
|
for ( const RimEnsembleCurveSet* curveSet : curveSets )
|
||||||
|
{
|
||||||
|
if ( curveSet && curveSet->summaryCaseCollection() )
|
||||||
{
|
{
|
||||||
auto addresses = curveSet->summaryCaseCollection()->ensembleSummaryAddresses();
|
auto addresses = curveSet->summaryCaseCollection()->ensembleSummaryAddresses();
|
||||||
addressSet.insert( addresses.begin(), addresses.end() );
|
addressSet.insert( addresses.begin(), addresses.end() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
RimSummaryCurveCollection* curveCollection = nullptr;
|
RimSummaryCurveCollection* curveCollection = nullptr;
|
||||||
this->firstAncestorOrThisOfType( curveCollection );
|
this->firstAncestorOrThisOfType( curveCollection );
|
||||||
if ( curveCollection )
|
if ( curveCollection )
|
||||||
{
|
{
|
||||||
for ( auto curve : curveCollection->curvesForSourceStepping( m_sourceSteppingType ) )
|
for ( auto curve : curveCollection->curvesForSourceStepping( m_sourceSteppingType ) )
|
||||||
{
|
{
|
||||||
|
if ( !curve ) continue;
|
||||||
|
|
||||||
if ( isYAxisStepping() && curve->summaryCaseY() && curve->summaryCaseY()->summaryReader() )
|
if ( isYAxisStepping() && curve->summaryCaseY() && curve->summaryCaseY()->summaryReader() )
|
||||||
{
|
{
|
||||||
auto addresses = curve->summaryCaseY()->summaryReader()->allResultAddresses();
|
auto addresses = curve->summaryCaseY()->summaryReader()->allResultAddresses();
|
||||||
@ -640,6 +646,7 @@ std::set<RifEclipseSummaryAddress> RimSummaryPlotSourceStepping::adressesForSour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return addressSet;
|
return addressSet;
|
||||||
}
|
}
|
||||||
|
@ -308,9 +308,9 @@ void RiuQwtPlotCurve::drawSymbols( QPainter* painter,
|
|||||||
|
|
||||||
if ( sym )
|
if ( sym )
|
||||||
{
|
{
|
||||||
if ( m_perPointLabels.size() == pointsToDisplay.size() )
|
if ( m_perPointLabels.size() == static_cast<size_t>( pointsToDisplay.size() ) )
|
||||||
{
|
{
|
||||||
for ( int i = 0; i < (int)pointsToDisplay.size(); ++i )
|
for ( int i = 0; i < pointsToDisplay.size(); ++i )
|
||||||
{
|
{
|
||||||
sym->renderSymbolLabel( painter, pointsToDisplay[i], m_perPointLabels[i] );
|
sym->renderSymbolLabel( painter, pointsToDisplay[i], m_perPointLabels[i] );
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user