Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring preparing for cross plot curve changes #10616

Merged
merged 7 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 108 additions & 35 deletions ApplicationLibCode/Application/RiaSummaryCurveDefinition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
/////////////////////////////////////////////////////////////////////////////////

#include "RiaSummaryCurveDefinition.h"
#include "RiaStdStringTools.h"

#include "RifSummaryReaderInterface.h"

#include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h"

Expand All @@ -28,7 +30,9 @@
///
//--------------------------------------------------------------------------------------------------
RiaSummaryCurveDefinition::RiaSummaryCurveDefinition()
: m_summaryCase( nullptr )
: m_summaryCaseY( nullptr )
, m_summaryCaseX( nullptr )
, m_summaryAddressX( RifEclipseSummaryAddress::timeAddress() )
, m_ensemble( nullptr )
, m_isEnsembleCurve( false )
{
Expand All @@ -40,8 +44,10 @@ RiaSummaryCurveDefinition::RiaSummaryCurveDefinition()
RiaSummaryCurveDefinition::RiaSummaryCurveDefinition( RimSummaryCase* summaryCase,
const RifEclipseSummaryAddress& summaryAddress,
bool isEnsembleCurve )
: m_summaryCase( summaryCase )
, m_summaryAddress( summaryAddress )
: m_summaryCaseY( summaryCase )
, m_summaryAddressY( summaryAddress )
, m_summaryCaseX( nullptr )
, m_summaryAddressX( RifEclipseSummaryAddress::timeAddress() )
, m_ensemble( nullptr )
, m_isEnsembleCurve( isEnsembleCurve )
{
Expand All @@ -51,8 +57,10 @@ RiaSummaryCurveDefinition::RiaSummaryCurveDefinition( RimSummaryCase*
///
//--------------------------------------------------------------------------------------------------
RiaSummaryCurveDefinition::RiaSummaryCurveDefinition( RimSummaryCaseCollection* ensemble, const RifEclipseSummaryAddress& summaryAddress )
: m_summaryCase( nullptr )
, m_summaryAddress( summaryAddress )
: m_summaryCaseY( nullptr )
, m_summaryAddressY( summaryAddress )
, m_summaryCaseX( nullptr )
, m_summaryAddressX( RifEclipseSummaryAddress::timeAddress() )
, m_ensemble( ensemble )
, m_isEnsembleCurve( true )
{
Expand All @@ -61,9 +69,9 @@ RiaSummaryCurveDefinition::RiaSummaryCurveDefinition( RimSummaryCaseCollection*
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryCase* RiaSummaryCurveDefinition::summaryCase() const
RimSummaryCase* RiaSummaryCurveDefinition::summaryCaseY() const
{
return m_summaryCase;
return m_summaryCaseY;
}

//--------------------------------------------------------------------------------------------------
Expand All @@ -77,9 +85,9 @@ RimSummaryCaseCollection* RiaSummaryCurveDefinition::ensemble() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RifEclipseSummaryAddress& RiaSummaryCurveDefinition::summaryAddress() const
RifEclipseSummaryAddress RiaSummaryCurveDefinition::summaryAddressY() const
{
return m_summaryAddress;
return m_summaryAddressY;
}

//--------------------------------------------------------------------------------------------------
Expand All @@ -93,37 +101,102 @@ bool RiaSummaryCurveDefinition::isEnsembleCurve() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaSummaryCurveDefinition::setSummaryAddress( const RifEclipseSummaryAddress& address )
void RiaSummaryCurveDefinition::setSummaryAddressY( const RifEclipseSummaryAddress& address )
{
m_summaryAddressY = address;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaSummaryCurveDefinition::setSummaryCaseX( RimSummaryCase* summaryCase )
{
m_summaryCaseX = summaryCase;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaSummaryCurveDefinition::setSummaryAddressX( const RifEclipseSummaryAddress& summaryAddress )
{
m_summaryAddressX = summaryAddress;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryCase* RiaSummaryCurveDefinition::summaryCaseX() const
{
m_summaryAddress = address;
return m_summaryCaseX;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseSummaryAddress RiaSummaryCurveDefinition::summaryAddressX() const
{
return m_summaryAddressX;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaSummaryCurveDefinition::setIdentifierText( SummaryCategory category, const std::string& name )
{
if ( RifEclipseSummaryAddress::isDependentOnWellName( category ) )
{
m_summaryAddressY.setWellName( name );
m_summaryAddressX.setWellName( name );
}

int id = RiaStdStringTools::toInt( name );

switch ( category )
{
case RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_AQUIFER:
m_summaryAddressY.setAquiferNumber( id );
m_summaryAddressX.setAquiferNumber( id );
break;
case RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_REGION:
case RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_REGION_2_REGION:
m_summaryAddressY.setRegion( id );
m_summaryAddressX.setRegion( id );
break;
case RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_GROUP:
m_summaryAddressY.setGroupName( name );
m_summaryAddressX.setGroupName( name );
break;
default:
break;
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaSummaryCurveDefinition::resultValues( const RiaSummaryCurveDefinition& curveDefinition, gsl::not_null<std::vector<double>*> values )
{
if ( !curveDefinition.summaryAddress().isValid() ) return;
if ( !curveDefinition.summaryCase() ) return;
if ( !curveDefinition.summaryAddressY().isValid() ) return;
if ( !curveDefinition.summaryCaseY() ) return;

RifSummaryReaderInterface* reader = curveDefinition.summaryCase()->summaryReader();
RifSummaryReaderInterface* reader = curveDefinition.summaryCaseY()->summaryReader();
if ( !reader ) return;

reader->values( curveDefinition.summaryAddress(), values );
reader->values( curveDefinition.summaryAddressY(), values );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<time_t> RiaSummaryCurveDefinition::timeSteps( const RiaSummaryCurveDefinition& curveDefinition )
{
if ( !curveDefinition.summaryAddress().isValid() ) return {};
if ( !curveDefinition.summaryCase() ) return {};
if ( !curveDefinition.summaryAddressY().isValid() ) return {};
if ( !curveDefinition.summaryCaseY() ) return {};

RifSummaryReaderInterface* reader = curveDefinition.summaryCase()->summaryReader();
RifSummaryReaderInterface* reader = curveDefinition.summaryCaseY()->summaryReader();
if ( !reader ) return {};

return reader->timeSteps( curveDefinition.summaryAddress() );
return reader->timeSteps( curveDefinition.summaryAddressY() );
}

//--------------------------------------------------------------------------------------------------
Expand All @@ -132,12 +205,12 @@ std::vector<time_t> RiaSummaryCurveDefinition::timeSteps( const RiaSummaryCurveD
QString RiaSummaryCurveDefinition::curveDefinitionText() const
{
QString caseName;
if ( summaryCase() )
caseName = summaryCase()->displayCaseName();
if ( summaryCaseY() )
caseName = summaryCaseY()->displayCaseName();
else if ( ensemble() )
caseName = ensemble()->name();

return RiaSummaryCurveDefinition::curveDefinitionText( caseName, summaryAddress() );
return RiaSummaryCurveDefinition::curveDefinitionText( caseName, summaryAddressY() );
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -185,18 +258,18 @@ bool RiaSummaryCurveDefinition::operator<( const RiaSummaryCurveDefinition& othe
return m_ensemble < other.ensemble();
}

if ( m_summaryCase != other.summaryCase() )
if ( m_summaryCaseY != other.summaryCaseY() )
{
QString summaryCaseName;
QString otherSummaryCaseName;

if ( m_summaryCase )
if ( m_summaryCaseY )
{
summaryCaseName = m_summaryCase->displayCaseName();
summaryCaseName = m_summaryCaseY->displayCaseName();
}
if ( other.summaryCase() )
if ( other.summaryCaseY() )
{
otherSummaryCaseName = other.summaryCase()->displayCaseName();
otherSummaryCaseName = other.summaryCaseY()->displayCaseName();
}

// First check if names are different to ensure stable alphabetic sort
Expand All @@ -206,12 +279,12 @@ bool RiaSummaryCurveDefinition::operator<( const RiaSummaryCurveDefinition& othe
}

// Use pointer address, sorting will be be unstable
return m_summaryCase < other.summaryCase();
return m_summaryCaseY < other.summaryCaseY();
}

if ( m_summaryAddress != other.summaryAddress() )
if ( m_summaryAddressY != other.summaryAddressY() )
{
return ( m_summaryAddress < other.summaryAddress() );
return ( m_summaryAddressY < other.summaryAddressY() );
}

return m_isEnsembleCurve < other.isEnsembleCurve();
Expand All @@ -235,20 +308,20 @@ void RiaSummaryCurveDefinitionAnalyser::setCurveDefinitions( const std::vector<R
m_ensembles.insert( curveDef.ensemble() );
valid = true;
}
else if ( curveDef.summaryCase() )
else if ( curveDef.summaryCaseY() )
{
m_singleSummaryCases.insert( curveDef.summaryCase() );
m_singleSummaryCases.insert( curveDef.summaryCaseY() );

if ( curveDef.summaryCase()->ensemble() )
if ( curveDef.summaryCaseY()->ensemble() )
{
m_ensembles.insert( curveDef.summaryCase()->ensemble() );
m_ensembles.insert( curveDef.summaryCaseY()->ensemble() );
}
valid = true;
}

if ( valid )
{
const RifEclipseSummaryAddress& address = curveDef.summaryAddress();
const RifEclipseSummaryAddress& address = curveDef.summaryAddressY();

m_vectorNames.insert( address.vectorName() );
m_summaryAdresses.insert( address );
Expand Down
26 changes: 19 additions & 7 deletions ApplicationLibCode/Application/RiaSummaryCurveDefinition.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#pragma once

#include "RifEclipseSummaryAddress.h"
#include "RifEclipseSummaryAddressDefines.h"

#include <QString>

Expand All @@ -40,11 +41,20 @@ class RiaSummaryCurveDefinition
explicit RiaSummaryCurveDefinition( RimSummaryCase* summaryCase, const RifEclipseSummaryAddress& summaryAddress, bool isEnsembleCurve );
explicit RiaSummaryCurveDefinition( RimSummaryCaseCollection* ensemble, const RifEclipseSummaryAddress& summaryAddress );

RimSummaryCase* summaryCase() const;
const RifEclipseSummaryAddress& summaryAddress() const;
RimSummaryCaseCollection* ensemble() const;
bool isEnsembleCurve() const;
void setSummaryAddress( const RifEclipseSummaryAddress& address );
// Y Axis
RimSummaryCase* summaryCaseY() const;
RifEclipseSummaryAddress summaryAddressY() const;
RimSummaryCaseCollection* ensemble() const;
bool isEnsembleCurve() const;
void setSummaryAddressY( const RifEclipseSummaryAddress& address );

// X Axis
void setSummaryCaseX( RimSummaryCase* summaryCase );
void setSummaryAddressX( const RifEclipseSummaryAddress& summaryAddress );
RimSummaryCase* summaryCaseX() const;
RifEclipseSummaryAddress summaryAddressX() const;

void setIdentifierText( SummaryCategory category, const std::string& name );

bool operator<( const RiaSummaryCurveDefinition& other ) const;

Expand All @@ -57,8 +67,10 @@ class RiaSummaryCurveDefinition
static QString curveDefinitionText( const QString& caseName, const RifEclipseSummaryAddress& summaryAddress );

private:
RimSummaryCase* m_summaryCase;
RifEclipseSummaryAddress m_summaryAddress;
RimSummaryCase* m_summaryCaseY;
RifEclipseSummaryAddress m_summaryAddressY;
RimSummaryCase* m_summaryCaseX;
RifEclipseSummaryAddress m_summaryAddressX;
RimSummaryCaseCollection* m_ensemble;
bool m_isEnsembleCurve;
};
Expand Down
38 changes: 19 additions & 19 deletions ApplicationLibCode/Application/Tools/RiaOptionItemFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,65 +55,65 @@ void RiaOptionItemFactory::appendOptionItemsForEnsembleCurveSets( QList<caf::Pdm
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmOptionItemInfo RiaOptionItemFactory::optionItemFromSummaryType( RifEclipseSummaryAddressDefines::SummaryVarCategory summaryType )
caf::PdmOptionItemInfo RiaOptionItemFactory::optionItemFromSummaryType( RifEclipseSummaryAddressDefines::SummaryCategory summaryType )
{
auto uiText = caf::AppEnum<RifEclipseSummaryAddressDefines::SummaryVarCategory>::uiText( summaryType );
auto uiText = caf::AppEnum<RifEclipseSummaryAddressDefines::SummaryCategory>::uiText( summaryType );

// Use icons from https://github.com/equinor/webviz-subsurface-components

QString iconText;

switch ( summaryType )
{
case RifEclipseSummaryAddressDefines::SummaryVarCategory::SUMMARY_INVALID:
case RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_INVALID:
iconText = ":/summary/components/images/invalid.svg";
break;
case RifEclipseSummaryAddressDefines::SummaryVarCategory::SUMMARY_FIELD:
case RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_FIELD:
iconText = ":/summary/components/images/field.svg";
break;
case RifEclipseSummaryAddressDefines::SummaryVarCategory::SUMMARY_AQUIFER:
case RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_AQUIFER:
iconText = ":/summary/components/images/aquifer.svg";
break;
case RifEclipseSummaryAddressDefines::SummaryVarCategory::SUMMARY_NETWORK:
case RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_NETWORK:
iconText = ":/summary/components/images/network.svg";
break;
case RifEclipseSummaryAddressDefines::SummaryVarCategory::SUMMARY_MISC:
case RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_MISC:
iconText = ":/summary/components/images/misc.svg";
break;
case RifEclipseSummaryAddressDefines::SummaryVarCategory::SUMMARY_REGION:
case RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_REGION:
iconText = ":/summary/components/images/region.svg";
break;
case RifEclipseSummaryAddressDefines::SummaryVarCategory::SUMMARY_REGION_2_REGION:
case RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_REGION_2_REGION:
iconText = ":/summary/components/images/region-region.svg";
break;
case RifEclipseSummaryAddressDefines::SummaryVarCategory::SUMMARY_GROUP:
case RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_GROUP:
iconText = ":/summary/components/images/group.svg";
break;
case RifEclipseSummaryAddressDefines::SummaryVarCategory::SUMMARY_WELL:
case RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_WELL:
iconText = ":/summary/components/images/well.svg";
break;
case RifEclipseSummaryAddressDefines::SummaryVarCategory::SUMMARY_WELL_COMPLETION:
case RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_WELL_COMPLETION:
iconText = ":/summary/components/images/well-completion.svg";
break;
case RifEclipseSummaryAddressDefines::SummaryVarCategory::SUMMARY_WELL_LGR:
case RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_WELL_LGR:
iconText = ":/summary/components/images/well.svg";
break;
case RifEclipseSummaryAddressDefines::SummaryVarCategory::SUMMARY_WELL_COMPLETION_LGR:
case RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_WELL_COMPLETION_LGR:
iconText = ":/summary/components/images/well-completion.svg";
break;
case RifEclipseSummaryAddressDefines::SummaryVarCategory::SUMMARY_WELL_SEGMENT:
case RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_WELL_SEGMENT:
iconText = ":/summary/components/images/segment.svg";
break;
case RifEclipseSummaryAddressDefines::SummaryVarCategory::SUMMARY_BLOCK:
case RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_BLOCK:
iconText = ":/summary/components/images/block.svg";
break;
case RifEclipseSummaryAddressDefines::SummaryVarCategory::SUMMARY_BLOCK_LGR:
case RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_BLOCK_LGR:
iconText = ":/summary/components/images/block.svg";
break;
case RifEclipseSummaryAddressDefines::SummaryVarCategory::SUMMARY_IMPORTED:
case RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_IMPORTED:
iconText = ":/summary/components/images/others.svg";
break;
case RifEclipseSummaryAddressDefines::SummaryVarCategory::SUMMARY_ENSEMBLE_STATISTICS:
case RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_ENSEMBLE_STATISTICS:
break;
}

Expand Down
Loading