#770 Fixed Ailien curves bug

This commit is contained in:
Jacob Støren 2016-08-04 11:15:31 +02:00
parent 4bfef4ead0
commit 0d7a1e8bd7
2 changed files with 49 additions and 52 deletions

View File

@ -155,26 +155,7 @@ QList<caf::PdmOptionItemInfo> RimSummaryCurveFilter::calculateValueOptions(const
}
else if(fieldNeedingOptions == &m_uiFilterResultMultiSelection)
{
size_t caseCount = m_selectedSummaryCases.size();
std::set<RifEclipseSummaryAddress> addrUnion;
for(RimSummaryCase* currCase: m_selectedSummaryCases)
{
RifReaderEclipseSummary* reader = nullptr;
if(currCase && currCase->caseData()) reader = currCase->caseData()->summaryReader();
if(reader)
{
const std::vector<RifEclipseSummaryAddress> allAddresses = reader->allResultAddresses();
int addressCount = static_cast<int>(allAddresses.size());
for(int i = 0; i <addressCount; i++)
{
if(!m_summaryFilter->isIncludedByFilter(allAddresses[i])) continue;
addrUnion.insert(allAddresses[i]);
}
}
}
std::set<RifEclipseSummaryAddress> addrUnion = findPossibleSummaryAddresses();
for(const auto& address: addrUnion)
{
@ -310,7 +291,9 @@ void RimSummaryCurveFilter::syncCurvesFromUiSelection()
std::set<std::pair<RimSummaryCase*, RifEclipseSummaryAddress> > newCurveDefinitions;
// Populate the newCurveDefinitions from the Gui
std::set<RifEclipseSummaryAddress> 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<RifEclipseSummaryAddress> RimSummaryCurveFilter::findPossibleSummaryAddresses()
{
std::set<RifEclipseSummaryAddress> addrUnion;
for(RimSummaryCase* currCase: m_selectedSummaryCases)
{
RifReaderEclipseSummary* reader = nullptr;
if(currCase && currCase->caseData()) reader = currCase->caseData()->summaryReader();
if(reader)
{
const std::vector<RifEclipseSummaryAddress> allAddresses = reader->allResultAddresses();
int addressCount = static_cast<int>(allAddresses.size());
for(int i = 0; i <addressCount; i++)
{
if(!m_summaryFilter->isIncludedByFilter(allAddresses[i])) continue;
addrUnion.insert(allAddresses[i]);
}
}
}
return addrUnion;
}

View File

@ -60,22 +60,22 @@ public:
RimSummaryCurve* findRimCurveFromQwtCurve(const QwtPlotCurve* qwtCurve) const;
std::set<std::string> unitNames();
void updateCaseNameHasChanged();
void updateCaseNameHasChanged();
private:
void syncCurvesFromUiSelection();
void createCurvesFromCurveDefinitions(const std::set<std::pair<RimSummaryCase*, RifEclipseSummaryAddress> >& curveDefinitions);
void syncUiSelectionFromCurves();
std::set<RifEclipseSummaryAddress> findPossibleSummaryAddresses();
void createSetOfCasesAndResultAdresses(
const std::vector<RimSummaryCase*>& cases,
const RimSummaryFilter& filter,
std::set<std::pair<RimSummaryCase*, RifEclipseSummaryAddress> >* curveDefinitions) const;
void createSetOfCasesAndResultAdresses(
const std::vector<RimSummaryCase*>& cases,
const RimSummaryFilter& filter,
std::set<std::pair<RimSummaryCase*, RifEclipseSummaryAddress> >* curveDefinitions) const;
// Overridden PDM methods
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly);
virtual QList<caf::PdmOptionItemInfo> 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;