mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3339 Make order of summary curves in plot predictable.
* The issue is sorting on pointer address for ensembles and summary cases. Instead sort by name. * The crucial changes are in RiaSummaryCurveDefinition.cpp, RimSummaryCase and RimSummaryCaseCollection. * The rest of the changes are just fallout from changing the pure virtual method RimSummaryCase::caseName to be const. The rest just follows. * RimGridSummaryCase::caseName does alter something, but this variable was already declared mutable.
This commit is contained in:
@@ -144,11 +144,23 @@ bool RiaSummaryCurveDefinition::operator<(const RiaSummaryCurveDefinition& other
|
|||||||
{
|
{
|
||||||
if (m_summaryCase != other.summaryCase())
|
if (m_summaryCase != other.summaryCase())
|
||||||
{
|
{
|
||||||
|
// Try comparing the dereferenced objects first. They have a predictable sorting operator.
|
||||||
|
if (m_summaryCase && other.summaryCase())
|
||||||
|
{
|
||||||
|
return *m_summaryCase < *other.summaryCase();
|
||||||
|
}
|
||||||
|
// Sorting by pointer address, which may appear random to the user.
|
||||||
return m_summaryCase < other.summaryCase();
|
return m_summaryCase < other.summaryCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_ensemble != other.ensemble())
|
if (m_ensemble != other.ensemble())
|
||||||
{
|
{
|
||||||
|
// Try comparing the dereferenced objects first. They have a predictable sorting operator.
|
||||||
|
if (m_ensemble && other.ensemble())
|
||||||
|
{
|
||||||
|
return *m_ensemble < *other.ensemble();
|
||||||
|
}
|
||||||
|
// Sorting by pointer address, which may appear random to the user.
|
||||||
return (m_ensemble < other.ensemble());
|
return (m_ensemble < other.ensemble());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ RimCalculatedSummaryCase::~RimCalculatedSummaryCase()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
QString RimCalculatedSummaryCase::caseName()
|
QString RimCalculatedSummaryCase::caseName() const
|
||||||
{
|
{
|
||||||
return "Calculated";
|
return "Calculated";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public:
|
|||||||
RimCalculatedSummaryCase();
|
RimCalculatedSummaryCase();
|
||||||
virtual ~RimCalculatedSummaryCase();
|
virtual ~RimCalculatedSummaryCase();
|
||||||
|
|
||||||
virtual QString caseName() override;
|
virtual QString caseName() const override;
|
||||||
virtual void createSummaryReaderInterface() override;
|
virtual void createSummaryReaderInterface() override;
|
||||||
virtual RifSummaryReaderInterface* summaryReader() override;
|
virtual RifSummaryReaderInterface* summaryReader() override;
|
||||||
virtual void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath) override;
|
virtual void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath) override;
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ void RimDerivedEnsembleCase::calculate(const RifEclipseSummaryAddress& address)
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
QString RimDerivedEnsembleCase::caseName()
|
QString RimDerivedEnsembleCase::caseName() const
|
||||||
{
|
{
|
||||||
auto case1Name = m_summaryCase1->caseName();
|
auto case1Name = m_summaryCase1->caseName();
|
||||||
auto case2Name = m_summaryCase2->caseName();
|
auto case2Name = m_summaryCase2->caseName();
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public:
|
|||||||
|
|
||||||
void calculate(const RifEclipseSummaryAddress& address);
|
void calculate(const RifEclipseSummaryAddress& address);
|
||||||
|
|
||||||
virtual QString caseName() override;
|
virtual QString caseName() const override;
|
||||||
virtual void createSummaryReaderInterface() override;
|
virtual void createSummaryReaderInterface() override;
|
||||||
virtual RifSummaryReaderInterface* summaryReader() override;
|
virtual RifSummaryReaderInterface* summaryReader() override;
|
||||||
virtual void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath) override;
|
virtual void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath) override;
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ const std::vector<double>& RimEnsembleStatisticsCase::mean() const
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
QString RimEnsembleStatisticsCase::caseName()
|
QString RimEnsembleStatisticsCase::caseName() const
|
||||||
{
|
{
|
||||||
return "Ensemble Statistics";
|
return "Ensemble Statistics";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public:
|
|||||||
bool hasP90Data() const { return !m_p90Data.empty(); }
|
bool hasP90Data() const { return !m_p90Data.empty(); }
|
||||||
bool hasMeanData() const { return !m_meanData.empty(); }
|
bool hasMeanData() const { return !m_meanData.empty(); }
|
||||||
|
|
||||||
virtual QString caseName() override;
|
virtual QString caseName() const override;
|
||||||
virtual void createSummaryReaderInterface() override;
|
virtual void createSummaryReaderInterface() override;
|
||||||
virtual RifSummaryReaderInterface* summaryReader() override;
|
virtual RifSummaryReaderInterface* summaryReader() override;
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ QString RimFileSummaryCase::summaryHeaderFilename() const
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
QString RimFileSummaryCase::caseName()
|
QString RimFileSummaryCase::caseName() const
|
||||||
{
|
{
|
||||||
QFileInfo caseFileName(this->summaryHeaderFilename());
|
QFileInfo caseFileName(this->summaryHeaderFilename());
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public:
|
|||||||
virtual ~RimFileSummaryCase();
|
virtual ~RimFileSummaryCase();
|
||||||
|
|
||||||
virtual QString summaryHeaderFilename() const override;
|
virtual QString summaryHeaderFilename() const override;
|
||||||
virtual QString caseName() override;
|
virtual QString caseName() const override;
|
||||||
virtual void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath) override;
|
virtual void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath) override;
|
||||||
|
|
||||||
virtual void createSummaryReaderInterface() override;
|
virtual void createSummaryReaderInterface() override;
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ QString RimGridSummaryCase::summaryHeaderFilename() const
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
QString RimGridSummaryCase::caseName()
|
QString RimGridSummaryCase::caseName() const
|
||||||
{
|
{
|
||||||
if (m_eclipseCase()) m_cachedCaseName = caseNameFromEclipseCase(m_eclipseCase());
|
if (m_eclipseCase()) m_cachedCaseName = caseNameFromEclipseCase(m_eclipseCase());
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public:
|
|||||||
RimEclipseCase* associatedEclipseCase();
|
RimEclipseCase* associatedEclipseCase();
|
||||||
|
|
||||||
virtual QString summaryHeaderFilename() const override;
|
virtual QString summaryHeaderFilename() const override;
|
||||||
virtual QString caseName() override;
|
virtual QString caseName() const override;
|
||||||
virtual void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath) override;
|
virtual void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath) override;
|
||||||
|
|
||||||
virtual void createSummaryReaderInterface() override;
|
virtual void createSummaryReaderInterface() override;
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ RimObservedData::RimObservedData()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
QString RimObservedData::caseName()
|
QString RimObservedData::caseName() const
|
||||||
{
|
{
|
||||||
QFileInfo caseFileName(this->summaryHeaderFilename());
|
QFileInfo caseFileName(this->summaryHeaderFilename());
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class RimObservedData : public RimSummaryCase
|
|||||||
public:
|
public:
|
||||||
RimObservedData();
|
RimObservedData();
|
||||||
|
|
||||||
virtual QString caseName() override;
|
virtual QString caseName() const override;
|
||||||
virtual void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath) override;
|
virtual void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath) override;
|
||||||
|
|
||||||
QString identifierName() const;
|
QString identifierName() const;
|
||||||
|
|||||||
@@ -140,6 +140,14 @@ void RimSummaryCase::copyFrom(const RimSummaryCase& rhs)
|
|||||||
this->updateOptionSensitivity();
|
this->updateOptionSensitivity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
/// Sorting operator for sets and maps. Sorts by summary case short name.
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RimSummaryCase::operator<(const RimSummaryCase& rhs) const
|
||||||
|
{
|
||||||
|
return this->caseName() < rhs.caseName();
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public:
|
|||||||
virtual ~RimSummaryCase();
|
virtual ~RimSummaryCase();
|
||||||
|
|
||||||
virtual QString summaryHeaderFilename() const;
|
virtual QString summaryHeaderFilename() const;
|
||||||
virtual QString caseName() = 0;
|
virtual QString caseName() const = 0;
|
||||||
QString shortName() const;
|
QString shortName() const;
|
||||||
|
|
||||||
void updateAutoShortName();
|
void updateAutoShortName();
|
||||||
@@ -63,6 +63,7 @@ public:
|
|||||||
RimSummaryCaseCollection* ensemble() const;
|
RimSummaryCaseCollection* ensemble() const;
|
||||||
bool isEnsembleCase() const;
|
bool isEnsembleCase() const;
|
||||||
void copyFrom(const RimSummaryCase& rhs);
|
void copyFrom(const RimSummaryCase& rhs);
|
||||||
|
bool operator<(const RimSummaryCase& rhs) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
|
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
|
||||||
|
|||||||
@@ -425,6 +425,14 @@ bool RimSummaryCaseCollection::validateEnsembleCases(const std::vector<RimSummar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
/// Sorting operator for sets and maps. Sorts by name.
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RimSummaryCaseCollection::operator<(const RimSummaryCaseCollection& rhs) const
|
||||||
|
{
|
||||||
|
return name() < rhs.name();
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ public:
|
|||||||
void loadDataAndUpdate();
|
void loadDataAndUpdate();
|
||||||
|
|
||||||
static bool validateEnsembleCases(const std::vector<RimSummaryCase*> cases);
|
static bool validateEnsembleCases(const std::vector<RimSummaryCase*> cases);
|
||||||
|
bool operator<(const RimSummaryCaseCollection& rhs) const;
|
||||||
private:
|
private:
|
||||||
caf::PdmFieldHandle* userDescriptionField() override;
|
caf::PdmFieldHandle* userDescriptionField() override;
|
||||||
QString nameAndItemCount() const;
|
QString nameAndItemCount() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user