Skip to content

Commit

Permalink
Support cross plot curves in plot templates
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Sep 19, 2023
1 parent b89d403 commit 381ff37
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,28 @@ QString RicSaveMultiPlotTemplateFeature::createTextFromObject( RimSummaryMultiPl
replaceStrings( sourceStrings, summaryFieldKeyword, RicSummaryPlotTemplateTools::placeholderTextForSummaryCase(), objectAsText );
}

{
std::set<QString> sourceStrings;

const QString summaryFieldKeyword = RicSummaryPlotTemplateTools::summaryCaseXFieldKeyword();
for ( const auto& curve : summaryPlot->allCurves( RimSummaryDataSourceStepping::Axis::Y_AXIS ) )
{
if ( curve->axisTypeX() != RiaDefines::HorizontalAxisType::SUMMARY_VECTOR ) continue;

auto fieldHandle = curve->findField( summaryFieldKeyword );
if ( fieldHandle )
{
auto reference = caf::PdmReferenceHelper::referenceFromFieldToObject( fieldHandle, curve->summaryCaseX() );

sourceStrings.insert( reference );
}

addresses.push_back( curve->summaryAddressX() );
}

replaceStrings( sourceStrings, summaryFieldKeyword, RicSummaryPlotTemplateTools::placeholderTextForSummaryCaseX(), objectAsText );
}

{
std::set<QString> ensembleReferenceStrings;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,13 @@ void RicSummaryPlotTemplateTools::setValuesForPlaceholders( RimSummaryPlot*
auto summaryCurves = summaryPlot->allCurves( RimSummaryDataSourceStepping::Axis::Y_AXIS );
for ( const auto& curve : summaryCurves )
{
auto fieldHandle = curve->findField( RicSummaryPlotTemplateTools::summaryCaseFieldKeyword() );
if ( fieldHandle )
auto summaryCaseHandle = curve->findField( RicSummaryPlotTemplateTools::summaryCaseFieldKeyword() );
if ( summaryCaseHandle )
{
bool conversionOk = false;
const QString placeholderString = RicSummaryPlotTemplateTools::placeholderTextForSummaryCase();

auto referenceString = fieldHandle->xmlCapability()->referenceString();
auto referenceString = summaryCaseHandle->xmlCapability()->referenceString();
int indexValue = RicSummaryPlotTemplateTools::findValueForKeyword( placeholderString, referenceString, &conversionOk );

if ( conversionOk && indexValue >= 0 && indexValue < static_cast<int>( selectedSummaryCases.size() ) )
Expand All @@ -266,12 +266,37 @@ void RicSummaryPlotTemplateTools::setValuesForPlaceholders( RimSummaryPlot*
}
}

auto summaryCaseXHandle = curve->findField( RicSummaryPlotTemplateTools::summaryCaseXFieldKeyword() );
if ( summaryCaseXHandle )
{
bool conversionOk = false;
const QString placeholderString = RicSummaryPlotTemplateTools::placeholderTextForSummaryCaseX();

auto referenceString = summaryCaseXHandle->xmlCapability()->referenceString();
int indexValue = RicSummaryPlotTemplateTools::findValueForKeyword( placeholderString, referenceString, &conversionOk );

if ( conversionOk && indexValue >= 0 && indexValue < static_cast<int>( selectedSummaryCases.size() ) )
{
auto summaryCase = selectedSummaryCases[static_cast<int>( indexValue )];
curve->setSummaryCaseX( summaryCase );
}
}

// Replace placeholders with object names from selection
auto curveAdr = curve->summaryAddressY();
setPlaceholderWellName( &curveAdr, wellNames );
setPlaceholderGroupName( &curveAdr, groupNames );
setPlaceholderRegion( &curveAdr, regions );
curve->setSummaryAddressY( curveAdr );

if ( curve->axisTypeX() == RiaDefines::HorizontalAxisType::SUMMARY_VECTOR )
{
auto curveAdr = curve->summaryAddressX();
setPlaceholderWellName( &curveAdr, wellNames );
setPlaceholderGroupName( &curveAdr, groupNames );
setPlaceholderRegion( &curveAdr, regions );
curve->setSummaryAddressX( curveAdr );
}
}

for ( const auto& curveSet : summaryPlot->curveSets() )
Expand Down Expand Up @@ -493,6 +518,14 @@ QString RicSummaryPlotTemplateTools::summaryCaseFieldKeyword()
return "SummaryCase";
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicSummaryPlotTemplateTools::summaryCaseXFieldKeyword()
{
return "SummaryCaseX";
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand All @@ -509,6 +542,14 @@ QString RicSummaryPlotTemplateTools::placeholderTextForSummaryCase()
return "__CASE_NAME__";
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicSummaryPlotTemplateTools::placeholderTextForSummaryCaseX()
{
return "__CASE_NAME_X__";
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ class RicSummaryPlotTemplateTools
static std::vector<QString> selectDefaultPlotTemplates( std::vector<QString> currentSelection );

static QString summaryCaseFieldKeyword();
static QString summaryCaseXFieldKeyword();
static QString summaryGroupFieldKeyword();

static QString placeholderTextForSummaryCase();
static QString placeholderTextForSummaryCaseX();
static QString placeholderTextForSummaryGroup();
static QString placeholderTextForWell();
static QString placeholderTextForGroup();
Expand Down

0 comments on commit 381ff37

Please sign in to comment.