#3902 Summary Stepping : Fix issues for well name, region and well group name

This commit is contained in:
Magne Sjaastad committed 2018-12-18 22:55:35 +01:00
1 parent a442ddff04
commit cad072ba0b
4 files changed
+118 -116

No files matched your search

@@ -520,14 +520,14 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::ensembleStatisticsAddress(con
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RifEclipseSummaryAddress::isDependentOnWellName(const RifEclipseSummaryAddress& address) bool RifEclipseSummaryAddress::isDependentOnWellName(SummaryVarCategory category)
{ {
// clang-format off // clang-format off
if (address.category() == SUMMARY_WELL || if (category == SUMMARY_WELL ||
address.category() == SUMMARY_WELL_COMPLETION || category == SUMMARY_WELL_COMPLETION ||
address.category() == SUMMARY_WELL_COMPLETION_LGR || category == SUMMARY_WELL_COMPLETION_LGR ||
address.category() == SUMMARY_WELL_LGR || category == SUMMARY_WELL_LGR ||
address.category() == SUMMARY_WELL_SEGMENT) category == SUMMARY_WELL_SEGMENT)
{ {
return true; return true;
} }
@@ -144,7 +144,7 @@ public:
static RifEclipseSummaryAddress importedAddress(const std::string& quantityName); static RifEclipseSummaryAddress importedAddress(const std::string& quantityName);
static RifEclipseSummaryAddress ensembleStatisticsAddress(const std::string& quantityName, const std::string& dataQuantityName); static RifEclipseSummaryAddress ensembleStatisticsAddress(const std::string& quantityName, const std::string& dataQuantityName);
static bool isDependentOnWellName(const RifEclipseSummaryAddress& address); static bool isDependentOnWellName(SummaryVarCategory category);
// Access methods // Access methods
@@ -37,6 +37,7 @@
#include "RiuPlotMainWindow.h" #include "RiuPlotMainWindow.h"
#include "RiaStdStringTools.h"
#include "cafPdmUiComboBoxEditor.h" #include "cafPdmUiComboBoxEditor.h"
#include "cafPdmUiItem.h" #include "cafPdmUiItem.h"
#include "cafPdmUiListEditor.h" #include "cafPdmUiListEditor.h"
@@ -370,7 +371,7 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi(const caf::PdmFieldHandle* c
{ {
caf::PdmPointer<caf::PdmObjectHandle> variantHandle = oldValue.value<caf::PdmPointer<caf::PdmObjectHandle>>(); caf::PdmPointer<caf::PdmObjectHandle> variantHandle = oldValue.value<caf::PdmPointer<caf::PdmObjectHandle>>();
RimSummaryCase* previousCase = dynamic_cast<RimSummaryCase*>(variantHandle.p()); RimSummaryCase* previousCase = dynamic_cast<RimSummaryCase*>(variantHandle.p());
for (auto curve : curves) for (auto curve : curves)
{ {
if (isYAxisStepping()) if (isYAxisStepping())
@@ -430,23 +431,15 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi(const caf::PdmFieldHandle* c
if (isYAxisStepping()) if (isYAxisStepping())
{ {
RifEclipseSummaryAddress adr = curve->summaryAddressY(); RifEclipseSummaryAddress adr = curve->summaryAddressY();
if (RifEclipseSummaryAddress::isDependentOnWellName(adr)) updateAddressIfMatching(oldValue, newValue, RifEclipseSummaryAddress::SUMMARY_WELL, &adr);
{ curve->setSummaryAddressY(adr);
adr.setWellName(m_wellName().toStdString());
curve->setSummaryAddressY(adr);
}
} }
if (isXAxisStepping()) if (isXAxisStepping())
{ {
RifEclipseSummaryAddress adr = curve->summaryAddressX(); RifEclipseSummaryAddress adr = curve->summaryAddressX();
if (RifEclipseSummaryAddress::isDependentOnWellName(adr)) updateAddressIfMatching(oldValue, newValue, RifEclipseSummaryAddress::SUMMARY_WELL, &adr);
{ curve->setSummaryAddressX(adr);
adr.setWellName(m_wellName().toStdString());
curve->setSummaryAddressX(adr);
}
} }
} }
@@ -455,11 +448,8 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi(const caf::PdmFieldHandle* c
for (auto curveSet : ensembleCurveColl->curveSets()) for (auto curveSet : ensembleCurveColl->curveSets())
{ {
auto adr = curveSet->summaryAddress(); auto adr = curveSet->summaryAddress();
if (RifEclipseSummaryAddress::isDependentOnWellName(adr)) updateAddressIfMatching(oldValue, newValue, RifEclipseSummaryAddress::SUMMARY_WELL, &adr);
{ curveSet->setSummaryAddress(adr);
adr.setWellName(m_wellName().toStdString());
curveSet->setSummaryAddress(adr);
}
} }
} }
@@ -472,36 +462,25 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi(const caf::PdmFieldHandle* c
if (isYAxisStepping()) if (isYAxisStepping())
{ {
RifEclipseSummaryAddress adr = curve->summaryAddressY(); RifEclipseSummaryAddress adr = curve->summaryAddressY();
if (adr.category() == RifEclipseSummaryAddress::SUMMARY_REGION) updateAddressIfMatching(oldValue, newValue, RifEclipseSummaryAddress::SUMMARY_REGION, &adr);
{ curve->setSummaryAddressY(adr);
adr.setRegion(m_region());
curve->setSummaryAddressY(adr);
}
} }
if (isXAxisStepping()) if (isXAxisStepping())
{ {
RifEclipseSummaryAddress adr = curve->summaryAddressX(); RifEclipseSummaryAddress adr = curve->summaryAddressX();
if (adr.category() == RifEclipseSummaryAddress::SUMMARY_REGION) updateAddressIfMatching(oldValue, newValue, RifEclipseSummaryAddress::SUMMARY_REGION, &adr);
{ curve->setSummaryAddressX(adr);
adr.setRegion(m_region());
curve->setSummaryAddressX(adr);
}
} }
}
if (ensembleCurveColl) if (ensembleCurveColl)
{
for (auto curveSet : ensembleCurveColl->curveSets())
{ {
for (auto curveSet : ensembleCurveColl->curveSets()) auto adr = curveSet->summaryAddress();
{ updateAddressIfMatching(oldValue, newValue, RifEclipseSummaryAddress::SUMMARY_REGION, &adr);
auto adr = curveSet->summaryAddress(); curveSet->setSummaryAddress(adr);
if (adr.category() == RifEclipseSummaryAddress::SUMMARY_REGION)
{
adr.setRegion(m_region());
curveSet->setSummaryAddress(adr);
}
}
} }
} }
@@ -513,12 +492,16 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi(const caf::PdmFieldHandle* c
{ {
if (isYAxisStepping()) if (isYAxisStepping())
{ {
updateCurveYAddressIfMatching(oldValueString, newValueString, curve); auto adr = curve->summaryAddressY();
updateHistoryAndSummaryQuantityIfMatching(oldValue, newValue, &adr);
curve->setSummaryAddressY(adr);
} }
if (isXAxisStepping()) if (isXAxisStepping())
{ {
updateCurveXAddressIfMatching(oldValueString, newValueString, curve); auto adr = curve->summaryAddressX();
updateHistoryAndSummaryQuantityIfMatching(oldValue, newValue, &adr);
curve->setSummaryAddressX(adr);
} }
} }
@@ -527,7 +510,7 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi(const caf::PdmFieldHandle* c
for (auto curveSet : ensembleCurveColl->curveSets()) for (auto curveSet : ensembleCurveColl->curveSets())
{ {
auto adr = curveSet->summaryAddress(); auto adr = curveSet->summaryAddress();
updateAddressIfMatching(oldValueString, newValueString, adr); updateHistoryAndSummaryQuantityIfMatching(oldValue, newValue, &adr);
curveSet->setSummaryAddress(adr); curveSet->setSummaryAddress(adr);
} }
} }
@@ -541,23 +524,15 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi(const caf::PdmFieldHandle* c
if (isYAxisStepping()) if (isYAxisStepping())
{ {
RifEclipseSummaryAddress adr = curve->summaryAddressY(); RifEclipseSummaryAddress adr = curve->summaryAddressY();
if (adr.category() == RifEclipseSummaryAddress::SUMMARY_WELL_GROUP) updateAddressIfMatching(oldValue, newValue, RifEclipseSummaryAddress::SUMMARY_WELL_GROUP, &adr);
{ curve->setSummaryAddressY(adr);
adr.setWellGroupName(m_wellGroupName().toStdString());
curve->setSummaryAddressY(adr);
}
} }
if (isXAxisStepping()) if (isXAxisStepping())
{ {
RifEclipseSummaryAddress adr = curve->summaryAddressX(); RifEclipseSummaryAddress adr = curve->summaryAddressX();
if (adr.category() == RifEclipseSummaryAddress::SUMMARY_WELL_GROUP) updateAddressIfMatching(oldValue, newValue, RifEclipseSummaryAddress::SUMMARY_WELL_GROUP, &adr);
{ curve->setSummaryAddressX(adr);
adr.setWellGroupName(m_wellGroupName().toStdString());
curve->setSummaryAddressX(adr);
}
} }
} }
@@ -566,11 +541,8 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi(const caf::PdmFieldHandle* c
for (auto curveSet : ensembleCurveColl->curveSets()) for (auto curveSet : ensembleCurveColl->curveSets())
{ {
auto adr = curveSet->summaryAddress(); auto adr = curveSet->summaryAddress();
if (adr.category() == RifEclipseSummaryAddress::SUMMARY_WELL_GROUP) updateAddressIfMatching(oldValue, newValue, RifEclipseSummaryAddress::SUMMARY_WELL_GROUP, &adr);
{ curveSet->setSummaryAddress(adr);
adr.setWellGroupName(m_wellGroupName().toStdString());
curveSet->setSummaryAddress(adr);
}
} }
} }
@@ -927,68 +899,78 @@ void RimSummaryPlotSourceStepping::modifyCurrentIndex(caf::PdmValueField* valueF
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimSummaryPlotSourceStepping::updateCurveYAddressIfMatching(const std::string& oldQuantity, bool RimSummaryPlotSourceStepping::updateAddressIfMatching(const QVariant& oldValue,
const std::string& newQuantity, const QVariant& newValue,
RimSummaryCurve* curve) RifEclipseSummaryAddress::SummaryVarCategory category,
RifEclipseSummaryAddress* adr)
{ {
if (!curve) return; if (!adr) return false;
auto curveAdr = curve->summaryAddressY(); if (category == RifEclipseSummaryAddress::SUMMARY_REGION)
if (curveAdr.quantityName() == oldQuantity)
{ {
curveAdr.setQuantityName(newQuantity); int oldInt = oldValue.toInt();
curve->setSummaryAddressY(curveAdr); int newInt = newValue.toInt();
if (adr->regionNumber() == oldInt)
{
adr->setRegion(newInt);
return true;
}
}
else if (category == RifEclipseSummaryAddress::SUMMARY_WELL_GROUP)
{
std::string oldString = oldValue.toString().toStdString();
std::string newString = newValue.toString().toStdString();
if (adr->wellGroupName() == oldString)
{
adr->setWellGroupName(newString);
return true;
}
}
else if (RifEclipseSummaryAddress::isDependentOnWellName(category))
{
std::string oldString = oldValue.toString().toStdString();
std::string newString = newValue.toString().toStdString();
if (adr->wellName() == oldString)
{
adr->setWellName(newString);
return true;
}
} }
if (curveAdr.quantityName() == (oldQuantity + "H")) return false;
{
curveAdr.setQuantityName(newQuantity + "H");
curve->setSummaryAddressY(curveAdr);
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimSummaryPlotSourceStepping::updateCurveXAddressIfMatching(const std::string& oldQuantity, bool RimSummaryPlotSourceStepping::updateHistoryAndSummaryQuantityIfMatching(const QVariant& oldValue,
const std::string& newQuantity, const QVariant& newValue,
RimSummaryCurve* curve) RifEclipseSummaryAddress* adr)
{ {
if (!curve) return; if (!adr) return false;
auto curveAdr = curve->summaryAddressX(); std::string oldString = oldValue.toString().toStdString();
std::string newString = newValue.toString().toStdString();
if (curveAdr.quantityName() == oldQuantity) if (adr->quantityName() == oldString)
{ {
curveAdr.setQuantityName(newQuantity); adr->setQuantityName(newString);
curve->setSummaryAddressX(curveAdr);
}
if (curveAdr.quantityName() == (oldQuantity + "H"))
{
curveAdr.setQuantityName(newQuantity + "H");
curve->setSummaryAddressX(curveAdr);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimSummaryPlotSourceStepping::updateAddressIfMatching(const std::string& oldQuantity,
const std::string& newQuantity,
RifEclipseSummaryAddress& curveAdr)
{
if (curveAdr.quantityName() == oldQuantity)
{
curveAdr.setQuantityName(newQuantity);
return true; return true;
} }
if (curveAdr.quantityName() == (oldQuantity + "H")) std::string correspondingOldString = correspondingHistorySummaryCurveName(oldString);
std::string correspondingNewString = correspondingHistorySummaryCurveName(newString);
if (adr->quantityName() == correspondingOldString)
{ {
curveAdr.setQuantityName(newQuantity + "H"); adr->setQuantityName(correspondingNewString);
return true; return true;
} }
@@ -996,6 +978,24 @@ bool RimSummaryPlotSourceStepping::updateAddressIfMatching(const std::string&
return false; return false;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::string RimSummaryPlotSourceStepping::correspondingHistorySummaryCurveName(const std::string& curveName)
{
static std::string historyIdentifier = "H";
if (RiaStdStringTools::endsWith(curveName, historyIdentifier))
{
std::string candidate = curveName.substr(0, curveName.size() - 1);
return candidate;
}
else
{
return curveName + historyIdentifier;
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -97,14 +97,16 @@ private:
void modifyCurrentIndex(caf::PdmValueField* valueField, int indexOffset); void modifyCurrentIndex(caf::PdmValueField* valueField, int indexOffset);
static void static bool updateAddressIfMatching(const QVariant& oldValue,
updateCurveYAddressIfMatching(const std::string& oldQuantity, const std::string& newQuantity, RimSummaryCurve* curve); const QVariant& newValue,
RifEclipseSummaryAddress::SummaryVarCategory category,
RifEclipseSummaryAddress* adr);
static void static bool updateHistoryAndSummaryQuantityIfMatching(const QVariant& oldValue,
updateCurveXAddressIfMatching(const std::string& oldQuantity, const std::string& newQuantity, RimSummaryCurve* curve); const QVariant& newValue,
RifEclipseSummaryAddress* adr);
static bool static std::string correspondingHistorySummaryCurveName(const std::string& curveName);
updateAddressIfMatching(const std::string& oldQuantity, const std::string& newQuantity, RifEclipseSummaryAddress& adr);
private: private:
caf::PdmPtrField<RimSummaryCase*> m_summaryCase; caf::PdmPtrField<RimSummaryCase*> m_summaryCase;