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()
|
||||
{
|
||||
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 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -85,14 +89,3 @@ void RicCreatePlotFromTemplateByShortcutFeature::setupActionLook( QAction* actio
|
||||
QKeySequence keySeq( Qt::CTRL + Qt::Key_T );
|
||||
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;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
private:
|
||||
std::vector<RimSummaryCase*> selectedSummaryCases() const;
|
||||
};
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -19,12 +19,15 @@
|
||||
#include "RicSavePlotTemplateFeature.h"
|
||||
|
||||
#include "RicReloadPlotTemplatesFeature.h"
|
||||
#include "RicSummaryPlotTemplateTools.h"
|
||||
|
||||
#include "RiaGuiApplication.h"
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaPreferences.h"
|
||||
#include "RiaSummaryTools.h"
|
||||
|
||||
#include "RimEnsembleCurveSet.h"
|
||||
#include "RimEnsembleCurveSetCollection.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryCurve.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
@ -140,24 +143,53 @@ 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;
|
||||
|
||||
const QString summaryFieldKeyword = RicSummaryPlotTemplateTools::summaryCaseFieldKeyword();
|
||||
for ( const auto& curve : newSummaryPlot->summaryCurves() )
|
||||
{
|
||||
auto reference = fieldHandle->xmlCapability()->referenceString();
|
||||
caseReferenceStrings.insert( reference );
|
||||
auto fieldHandle = curve->findField( summaryFieldKeyword );
|
||||
if ( fieldHandle )
|
||||
{
|
||||
auto reference = fieldHandle->xmlCapability()->referenceString();
|
||||
caseReferenceStrings.insert( reference );
|
||||
}
|
||||
}
|
||||
|
||||
size_t index = 0;
|
||||
for ( const auto& s : caseReferenceStrings )
|
||||
{
|
||||
QString placeholderText = RicSummaryPlotTemplateTools::placeholderTextForSummaryCase();
|
||||
QString caseName = QString( "%1 %2" ).arg( placeholderText ).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 );
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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"
|
||||
@ -39,8 +41,10 @@
|
||||
#include "RiuPlotMainWindow.h"
|
||||
|
||||
#include "cafPdmUiPropertyViewDialog.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QRegularExpression>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@ -76,62 +80,144 @@ 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 )
|
||||
{
|
||||
RimSummaryPlotCollection* plotColl =
|
||||
RiaApplication::instance()->project()->mainPlotCollection()->summaryPlotCollection();
|
||||
if ( !summaryPlot ) return;
|
||||
|
||||
plotColl->summaryPlots.push_back( summaryPlot );
|
||||
summaryPlot->resolveReferencesRecursively();
|
||||
summaryPlot->initAfterReadRecursively();
|
||||
if ( selectedSummaryCases.empty() && selectedEnsembles.empty() ) return;
|
||||
|
||||
RimSummaryPlotCollection* plotColl = RiaApplication::instance()->project()->mainPlotCollection()->summaryPlotCollection();
|
||||
|
||||
plotColl->summaryPlots.push_back( summaryPlot );
|
||||
summaryPlot->resolveReferencesRecursively();
|
||||
summaryPlot->initAfterReadRecursively();
|
||||
|
||||
{
|
||||
// Replace single summary curves data sources
|
||||
|
||||
auto summaryCurves = summaryPlot->summaryCurves();
|
||||
|
||||
const QString summaryFieldKeyword = RicSummaryPlotTemplateTools::summaryCaseFieldKeyword();
|
||||
|
||||
int maximumIndexValue = -1;
|
||||
for ( const auto& curve : summaryCurves )
|
||||
{
|
||||
auto fieldHandle = curve->findField( "SummaryCase" );
|
||||
auto fieldHandle = curve->findField( summaryFieldKeyword );
|
||||
if ( fieldHandle )
|
||||
{
|
||||
bool conversionOk = false;
|
||||
const QString placeholderString = RicSummaryPlotTemplateTools::placeholderTextForSummaryCase();
|
||||
|
||||
auto referenceString = fieldHandle->xmlCapability()->referenceString();
|
||||
auto stringList = referenceString.split( " " );
|
||||
if ( stringList.size() == 2 )
|
||||
int indexValue = RicSummaryPlotTemplateTools::findValueForKeyword( placeholderString,
|
||||
referenceString,
|
||||
&conversionOk );
|
||||
|
||||
maximumIndexValue = std::max( maximumIndexValue, indexValue );
|
||||
|
||||
if ( conversionOk && indexValue >= 0 && indexValue < static_cast<int>( selectedSummaryCases.size() ) )
|
||||
{
|
||||
QString indexAsString = stringList[1];
|
||||
auto summaryCaseY = selectedSummaryCases[static_cast<int>( indexValue )];
|
||||
curve->setSummaryCaseY( summaryCaseY );
|
||||
|
||||
bool conversionOk = false;
|
||||
auto index = indexAsString.toUInt( &conversionOk );
|
||||
|
||||
if ( conversionOk && index < selectedSummaryCases.size() )
|
||||
auto currentAddressY = curve->summaryAddressY();
|
||||
if ( summaryCaseY->summaryReader() && !summaryCaseY->summaryReader()->hasAddress( currentAddressY ) )
|
||||
{
|
||||
auto summaryCaseY = selectedSummaryCases[index];
|
||||
curve->setSummaryCaseY( summaryCaseY );
|
||||
auto allAddresses = summaryCaseY->summaryReader()->allResultAddresses();
|
||||
|
||||
auto currentAddressY = curve->summaryAddressY();
|
||||
if ( summaryCaseY->summaryReader() &&
|
||||
!summaryCaseY->summaryReader()->hasAddress( currentAddressY ) )
|
||||
auto candidate = RicSummaryPlotTemplateTools::firstAddressByQuantity( currentAddressY,
|
||||
allAddresses );
|
||||
if ( candidate.category() != RifEclipseSummaryAddress::SUMMARY_INVALID )
|
||||
{
|
||||
auto allAddresses = summaryCaseY->summaryReader()->allResultAddresses();
|
||||
|
||||
auto candidate = RicSummaryPlotTemplateTools::firstAddressByQuantity( currentAddressY,
|
||||
allAddresses );
|
||||
if ( candidate.category() != RifEclipseSummaryAddress::SUMMARY_INVALID )
|
||||
{
|
||||
curve->setSummaryAddressY( candidate );
|
||||
}
|
||||
curve->setSummaryAddressY( candidate );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Create additional curves in selected case count is larger than template count
|
||||
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
|
||||
|
||||
plotColl->updateConnectedEditors();
|
||||
if ( !summaryCurves.empty() )
|
||||
{
|
||||
auto lastSummaryCurve = summaryCurves.back();
|
||||
|
||||
summaryPlot->loadDataAndUpdate();
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// 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();
|
||||
|
||||
summaryPlot->loadDataAndUpdate();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -255,6 +341,60 @@ 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;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
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();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
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 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,7 +52,17 @@ public:
|
||||
|
||||
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:
|
||||
static RifEclipseSummaryAddress firstAddressByQuantity( const RifEclipseSummaryAddress& sourceAddress,
|
||||
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 << "Separator";
|
||||
if ( dynamic_cast<RimSummaryCase*>( uiItem ) )
|
||||
if ( dynamic_cast<RimSummaryCase*>( uiItem ) || dynamic_cast<RimSummaryCaseCollection*>( uiItem ) )
|
||||
{
|
||||
menuBuilder << "RicCreatePlotFromSelectionFeature";
|
||||
menuBuilder << "RicCreatePlotFromTemplateByShortcutFeature";
|
||||
|
@ -615,28 +615,35 @@ std::set<RifEclipseSummaryAddress> RimSummaryPlotSourceStepping::adressesForSour
|
||||
auto curveSets = ensembleCollection->curveSetsForSourceStepping();
|
||||
for ( const RimEnsembleCurveSet* curveSet : curveSets )
|
||||
{
|
||||
auto addresses = curveSet->summaryCaseCollection()->ensembleSummaryAddresses();
|
||||
addressSet.insert( addresses.begin(), addresses.end() );
|
||||
if ( curveSet && curveSet->summaryCaseCollection() )
|
||||
{
|
||||
auto addresses = curveSet->summaryCaseCollection()->ensembleSummaryAddresses();
|
||||
addressSet.insert( addresses.begin(), addresses.end() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RimSummaryCurveCollection* curveCollection = nullptr;
|
||||
this->firstAncestorOrThisOfType( curveCollection );
|
||||
if ( curveCollection )
|
||||
{
|
||||
for ( auto curve : curveCollection->curvesForSourceStepping( m_sourceSteppingType ) )
|
||||
RimSummaryCurveCollection* curveCollection = nullptr;
|
||||
this->firstAncestorOrThisOfType( curveCollection );
|
||||
if ( curveCollection )
|
||||
{
|
||||
if ( isYAxisStepping() && curve->summaryCaseY() && curve->summaryCaseY()->summaryReader() )
|
||||
for ( auto curve : curveCollection->curvesForSourceStepping( m_sourceSteppingType ) )
|
||||
{
|
||||
auto addresses = curve->summaryCaseY()->summaryReader()->allResultAddresses();
|
||||
addressSet.insert( addresses.begin(), addresses.end() );
|
||||
}
|
||||
if ( !curve ) continue;
|
||||
|
||||
if ( isXAxisStepping() && curve->summaryCaseX() && curve->summaryCaseX()->summaryReader() )
|
||||
{
|
||||
auto addresses = curve->summaryCaseX()->summaryReader()->allResultAddresses();
|
||||
addressSet.insert( addresses.begin(), addresses.end() );
|
||||
if ( isYAxisStepping() && curve->summaryCaseY() && curve->summaryCaseY()->summaryReader() )
|
||||
{
|
||||
auto addresses = curve->summaryCaseY()->summaryReader()->allResultAddresses();
|
||||
addressSet.insert( addresses.begin(), addresses.end() );
|
||||
}
|
||||
|
||||
if ( isXAxisStepping() && curve->summaryCaseX() && curve->summaryCaseX()->summaryReader() )
|
||||
{
|
||||
auto addresses = curve->summaryCaseX()->summaryReader()->allResultAddresses();
|
||||
addressSet.insert( addresses.begin(), addresses.end() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -308,9 +308,9 @@ void RiuQwtPlotCurve::drawSymbols( QPainter* painter,
|
||||
|
||||
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] );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user