#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>
valueOptionsForBranchIndexField(const std::vector<const RigWellPath*>& simulationWellPaths);
static void appendSimWellBranchFieldsIfRequiredFromWellName(caf::PdmUiOrdering* uiOrdering, const QString& wellPathOrSimWellName,
const caf::PdmField<bool>& branchDetectionField,
const caf::PdmField<int>& branchIndexField);
static void appendSimWellBranchFieldsIfRequiredFromWellName(caf::PdmUiOrdering* uiOrdering,
const QString& wellPathOrSimWellName,
const caf::PdmField<bool>& branchDetectionField,
const caf::PdmField<int>& branchIndexField);
static void appendSimWellBranchFieldsIfRequiredFromSimWellName(caf::PdmUiOrdering* uiOrdering, const QString& simWellName,
const caf::PdmField<bool>& branchDetectionField,
const caf::PdmField<int>& branchIndexField);
const caf::PdmField<bool>& branchDetectionField,
const caf::PdmField<int>& branchIndexField);
static int clampBranchIndex(const QString& simWellName, int branchIndexValue, bool branchDetection);
};