Fix selection of multiple pressure/depth sources in plot

Use spaceship operator to fix issue for multiple pressure/depth curves

It was not possible to show two pressure/drop curves at the same time. This was caused by inconsistent implementation of operator< and operator==. Implement operator <=> to simplify the code.
This commit is contained in:
Magne Sjaastad
2023-03-13 14:34:16 +01:00
parent c8ebca6041
commit 40c329f3ac
4 changed files with 95 additions and 100 deletions

View File

@@ -55,23 +55,26 @@ const QDateTime& RiaRftPltCurveDefinition::timeStep() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaRftPltCurveDefinition::operator<( const RiaRftPltCurveDefinition& other ) const
auto RiaRftPltCurveDefinition::operator<=>( const RiaRftPltCurveDefinition& other ) const -> std::strong_ordering
{
if ( m_curveAddress.ensemble() != other.m_curveAddress.ensemble() )
{
// Sort by ensemble first, to make sure the ensemble curves are created and plotted before the single curves
RimSummaryCaseCollection* thisEnsemble = m_curveAddress.ensemble();
RimSummaryCaseCollection* otherEnsemble = other.m_curveAddress.ensemble();
if ( m_curveAddress.ensemble() ) return true;
return false;
if ( ( thisEnsemble && !otherEnsemble ) || ( !thisEnsemble && otherEnsemble ) )
{
// If one is an ensemble and the other is not, the ensemble should be first to make sure the ensemble curves are created and plotted
// before the single summary curves
return m_curveAddress.ensemble() <=> other.m_curveAddress.ensemble();
}
if ( m_curveAddress == other.m_curveAddress )
if ( ( m_curveAddress <=> other.m_curveAddress ) == std::strong_ordering::equal )
{
if ( m_wellName == other.m_wellName )
{
return m_timeStep < other.m_timeStep;
return m_timeStep.toTime_t() <=> other.m_timeStep.toTime_t();
}
return m_wellName < other.m_wellName;
return m_wellName.toStdString() <=> other.m_wellName.toStdString();
}
return m_curveAddress < other.m_curveAddress;
return m_curveAddress <=> other.m_curveAddress;
}

View File

@@ -39,7 +39,7 @@ public:
const QString& wellName() const;
const QDateTime& timeStep() const;
bool operator<( const RiaRftPltCurveDefinition& other ) const;
auto operator<=>( const RiaRftPltCurveDefinition& rhs ) const -> std::strong_ordering;
private:
RifDataSourceForRftPlt m_curveAddress;