#2127 Clamp sim well branch index to valid range

This commit is contained in:
Magne Sjaastad 2017-12-08 10:23:36 +01:00
parent 0e5e88008a
commit 46bad03c4a
6 changed files with 41 additions and 10 deletions

View File

@ -106,3 +106,23 @@ void RiaSimWellBranchTools::appendSimWellBranchFieldsIfRequiredFromSimWellName(c
} }
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RiaSimWellBranchTools::clampBranchIndex(const QString& simWellName, int branchIndexValue, bool branchDetection)
{
auto branches = RiaSimWellBranchTools::simulationWellBranches(simWellName, branchDetection);
if (branches.size() == 0)
{
return -1;
}
if (branchIndexValue >= branches.size())
{
branchIndexValue = static_cast<int>(branches.size()) - 1;
}
return branchIndexValue;
}

View File

@ -44,11 +44,14 @@ public:
static QList<caf::PdmOptionItemInfo> static QList<caf::PdmOptionItemInfo>
valueOptionsForBranchIndexField(const std::vector<const RigWellPath*>& simulationWellPaths); valueOptionsForBranchIndexField(const std::vector<const RigWellPath*>& simulationWellPaths);
static void appendSimWellBranchFieldsIfRequiredFromWellName(caf::PdmUiOrdering* uiOrdering, const QString& wellPathOrSimWellName, static void appendSimWellBranchFieldsIfRequiredFromWellName(caf::PdmUiOrdering* uiOrdering,
const caf::PdmField<bool>& branchDetectionField, const QString& wellPathOrSimWellName,
const caf::PdmField<int>& branchIndexField); const caf::PdmField<bool>& branchDetectionField,
const caf::PdmField<int>& branchIndexField);
static void appendSimWellBranchFieldsIfRequiredFromSimWellName(caf::PdmUiOrdering* uiOrdering, const QString& simWellName, static void appendSimWellBranchFieldsIfRequiredFromSimWellName(caf::PdmUiOrdering* uiOrdering, const QString& simWellName,
const caf::PdmField<bool>& branchDetectionField, const caf::PdmField<bool>& branchDetectionField,
const caf::PdmField<int>& branchIndexField); const caf::PdmField<int>& branchIndexField);
static int clampBranchIndex(const QString& simWellName, int branchIndexValue, bool branchDetection);
}; };

View File

@ -704,6 +704,9 @@ void RimWellRftPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c
else if (changedField == &m_branchIndex || else if (changedField == &m_branchIndex ||
changedField == &m_branchDetection) changedField == &m_branchDetection)
{ {
const QString simWellName = associatedSimWellName();
m_branchIndex = RiaSimWellBranchTools::clampBranchIndex(simWellName, m_branchIndex, m_branchDetection);
updateFormationsOnPlot(); updateFormationsOnPlot();
syncCurvesFromUiSelection(); syncCurvesFromUiSelection();

View File

@ -581,12 +581,11 @@ void RimWellLogExtractionCurve::defineUiOrdering(QString uiConfigName, caf::PdmU
else else
{ {
curveDataGroup->add(&m_simWellName); curveDataGroup->add(&m_simWellName);
curveDataGroup->add(&m_branchDetection);
if ( simulationWellBranches().size() > 1 ) RiaSimWellBranchTools::appendSimWellBranchFieldsIfRequiredFromSimWellName(curveDataGroup,
{ m_simWellName,
curveDataGroup->add(&m_branchIndex); m_branchDetection,
} m_branchIndex);
} }
if (eclipseCase) if (eclipseCase)

View File

@ -467,6 +467,10 @@ void RimWellLogRftCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedFiel
else if (changedField == &m_branchDetection || else if (changedField == &m_branchDetection ||
changedField == &m_branchIndex) changedField == &m_branchIndex)
{ {
QString simWellName = RimWellPlotTools::simWellName(m_wellName);
m_branchIndex = RiaSimWellBranchTools::clampBranchIndex(simWellName, m_branchIndex, m_branchDetection);
updateWellChannelNameAndTimeStep(); updateWellChannelNameAndTimeStep();
this->loadDataAndUpdate(true); this->loadDataAndUpdate(true);
} }

View File

@ -281,6 +281,8 @@ void RimWellLogTrack::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
else if (changedField == &m_formationBranchIndex || else if (changedField == &m_formationBranchIndex ||
changedField == &m_formationBranchDetection) changedField == &m_formationBranchDetection)
{ {
m_formationBranchIndex = RiaSimWellBranchTools::clampBranchIndex(m_formationSimWellName, m_formationBranchIndex, m_formationBranchDetection);
loadDataAndUpdate(); loadDataAndUpdate();
} }
} }