From 0d7a1e8bd7558be8ded668a8f9e8a61899f1efd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 4 Aug 2016 11:15:31 +0200 Subject: [PATCH] #770 Fixed Ailien curves bug --- .../RimSummaryCurveFilter.cpp | 85 +++++++++---------- .../ProjectDataModel/RimSummaryCurveFilter.h | 16 ++-- 2 files changed, 49 insertions(+), 52 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimSummaryCurveFilter.cpp b/ApplicationCode/ProjectDataModel/RimSummaryCurveFilter.cpp index 4c4d4c55c7..2d54a9cf72 100644 --- a/ApplicationCode/ProjectDataModel/RimSummaryCurveFilter.cpp +++ b/ApplicationCode/ProjectDataModel/RimSummaryCurveFilter.cpp @@ -155,26 +155,7 @@ QList RimSummaryCurveFilter::calculateValueOptions(const } else if(fieldNeedingOptions == &m_uiFilterResultMultiSelection) { - size_t caseCount = m_selectedSummaryCases.size(); - std::set addrUnion; - - for(RimSummaryCase* currCase: m_selectedSummaryCases) - { - RifReaderEclipseSummary* reader = nullptr; - if(currCase && currCase->caseData()) reader = currCase->caseData()->summaryReader(); - - if(reader) - { - const std::vector allAddresses = reader->allResultAddresses(); - int addressCount = static_cast(allAddresses.size()); - - for(int i = 0; i isIncludedByFilter(allAddresses[i])) continue; - addrUnion.insert(allAddresses[i]); - } - } - } + std::set addrUnion = findPossibleSummaryAddresses(); for(const auto& address: addrUnion) { @@ -310,7 +291,9 @@ void RimSummaryCurveFilter::syncCurvesFromUiSelection() std::set > newCurveDefinitions; // Populate the newCurveDefinitions from the Gui - + + std::set addrUnion = findPossibleSummaryAddresses(); + for (RimSummaryCase* currentCase: m_selectedSummaryCases) { if (!currentCase || !currentCase->caseData() || !currentCase->caseData()->summaryReader()) continue; @@ -320,30 +303,13 @@ void RimSummaryCurveFilter::syncCurvesFromUiSelection() for(const RifEclipseSummaryAddress& addr: m_uiFilterResultMultiSelection.v()) { if(!reader->hasAddress(addr)) continue; - + if (addrUnion.count(addr) == 0 ) continue; // Wash the possible "old" ui selection with new filter + newCurveDefinitions.insert(std::make_pair(currentCase, addr)); } } - #if 0 - // Delete all existing curves that is not matching - // Remove the entries in the search set that we already have - for(RimSummaryCurve* curve: m_curves) - { - auto foundIt = newCurveDefinitions.find(std::make_pair(curve->summaryCase(), curve->summaryAddress() )); - if (foundIt == newCurveDefinitions.end()) - { - delete curve; - } - else - { - newCurveDefinitions.erase(foundIt); - } - } - m_curves.removeChildObject(nullptr); - #else m_curves.deleteAllChildObjects(); - #endif createCurvesFromCurveDefinitions(newCurveDefinitions); } @@ -364,11 +330,14 @@ void RimSummaryCurveFilter::syncUiSelectionFromCurves() referredCases.insert(curve->summaryCase()); } - m_selectedSummaryCases.clear(); - - for (RimSummaryCase* currCase: referredCases) + if (m_curves.size()) // Only sync the selected cases if we actually have some curves. To avoid user getting an empty variable list accidentally { - m_selectedSummaryCases.push_back(currCase); + m_selectedSummaryCases.clear(); + + for(RimSummaryCase* currCase: referredCases) + { + m_selectedSummaryCases.push_back(currCase); + } } m_uiFilterResultMultiSelection.v().clear(); @@ -496,3 +465,31 @@ void RimSummaryCurveFilter::updateCaseNameHasChanged() curve->updateConnectedEditors(); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RimSummaryCurveFilter::findPossibleSummaryAddresses() +{ + std::set addrUnion; + + for(RimSummaryCase* currCase: m_selectedSummaryCases) + { + RifReaderEclipseSummary* reader = nullptr; + if(currCase && currCase->caseData()) reader = currCase->caseData()->summaryReader(); + + if(reader) + { + const std::vector allAddresses = reader->allResultAddresses(); + int addressCount = static_cast(allAddresses.size()); + + for(int i = 0; i isIncludedByFilter(allAddresses[i])) continue; + addrUnion.insert(allAddresses[i]); + } + } + } + + return addrUnion; +} diff --git a/ApplicationCode/ProjectDataModel/RimSummaryCurveFilter.h b/ApplicationCode/ProjectDataModel/RimSummaryCurveFilter.h index b8e84c6901..7cdf810424 100644 --- a/ApplicationCode/ProjectDataModel/RimSummaryCurveFilter.h +++ b/ApplicationCode/ProjectDataModel/RimSummaryCurveFilter.h @@ -60,22 +60,22 @@ public: RimSummaryCurve* findRimCurveFromQwtCurve(const QwtPlotCurve* qwtCurve) const; std::set unitNames(); - void updateCaseNameHasChanged(); + void updateCaseNameHasChanged(); + private: void syncCurvesFromUiSelection(); - void createCurvesFromCurveDefinitions(const std::set >& curveDefinitions); - void syncUiSelectionFromCurves(); + std::set findPossibleSummaryAddresses(); - void createSetOfCasesAndResultAdresses( - const std::vector& cases, - const RimSummaryFilter& filter, - std::set >* curveDefinitions) const; + void createSetOfCasesAndResultAdresses( + const std::vector& cases, + const RimSummaryFilter& filter, + std::set >* curveDefinitions) const; // Overridden PDM methods virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); - virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly); + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly); virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute) override;