#3276 Make curve data source more robust.

This commit is contained in:
Gaute Lindkvist 2018-08-29 15:01:17 +02:00
parent 9262873846
commit 655803601e
2 changed files with 104 additions and 41 deletions

View File

@ -78,6 +78,22 @@ void RimWellLogCurveCommonDataSource::setCaseToApply(RimCase* val)
m_case = val; m_case = val;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimWellLogCurveCommonDataSource::trajectoryTypeToApply() const
{
return m_trajectoryType();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogCurveCommonDataSource::setTrajectoryTypeToApply(int val)
{
m_trajectoryType = val;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -94,6 +110,38 @@ void RimWellLogCurveCommonDataSource::setWellPathToApply(RimWellPath* val)
m_wellPath = val; m_wellPath = val;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimWellLogCurveCommonDataSource::branchIndexToApply() const
{
return m_branchIndex;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogCurveCommonDataSource::setBranchIndexToApply(int val)
{
m_branchIndex = val;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::Tristate RimWellLogCurveCommonDataSource::branchDetectionToApply() const
{
return m_branchDetection.v();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogCurveCommonDataSource::setBranchDetectionToApply(caf::Tristate::State val)
{
m_branchDetection.v() = val;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -102,6 +150,14 @@ QString RimWellLogCurveCommonDataSource::simWellNameToApply() const
return m_simWellName(); return m_simWellName();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogCurveCommonDataSource::setSimWellNameToApply(const QString& val)
{
m_simWellName = val;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -118,23 +174,40 @@ void RimWellLogCurveCommonDataSource::setTimeStepToApply(int val)
m_timeStep = val; m_timeStep = val;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogCurveCommonDataSource::resetDefaultOptions()
{
setCaseToApply(nullptr);
setTrajectoryTypeToApply(-1);
setWellPathToApply(nullptr);
setBranchIndexToApply(-1);
setBranchDetectionToApply(caf::Tristate::State::PartiallyTrue);
setSimWellNameToApply(QString(""));
setTimeStepToApply(-1);
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellLogCurveCommonDataSource::updateDefaultOptions(const std::vector<RimWellLogCurve*>& curves) void RimWellLogCurveCommonDataSource::updateDefaultOptions(const std::vector<RimWellLogCurve*>& curves)
{ {
// Reset all options in the UI
resetDefaultOptions();
// Check to see if the parameters are unique // Check to see if the parameters are unique
std::set<RimCase*> uniqueCases; std::set<RimCase*> uniqueCases;
std::set<int> uniqueTrajectoryTypes; std::set<int> uniqueTrajectoryTypes;
std::set<RimWellPath*> uniqueWellPaths; std::set<RimWellPath*> uniqueWellPaths;
std::set<QString> uniqueWellNames; std::set<QString> uniqueWellNames;
std::set<int> uniqueTimeSteps; std::set<int> uniqueTimeSteps;
std::set<bool> uniqueBranchDetection; std::set<bool> uniqueBranchDetection;
std::set<int> uniqueBranchIndex; std::set<int> uniqueBranchIndex;
for (RimWellLogCurve* curve : curves) for (RimWellLogCurve* curve : curves)
{ {
RimWellLogExtractionCurve* extractionCurve = dynamic_cast<RimWellLogExtractionCurve*>(curve); RimWellLogExtractionCurve* extractionCurve = dynamic_cast<RimWellLogExtractionCurve*>(curve);
RimWellLogFileCurve* fileCurve = dynamic_cast<RimWellLogFileCurve*>(curve);
if (extractionCurve) if (extractionCurve)
{ {
uniqueCases.insert(extractionCurve->rimCase()); uniqueCases.insert(extractionCurve->rimCase());
@ -145,16 +218,18 @@ void RimWellLogCurveCommonDataSource::updateDefaultOptions(const std::vector<Rim
uniqueBranchDetection.insert(extractionCurve->branchDetection()); uniqueBranchDetection.insert(extractionCurve->branchDetection());
uniqueBranchIndex.insert(extractionCurve->branchIndex()); uniqueBranchIndex.insert(extractionCurve->branchIndex());
} }
else if (fileCurve)
{
uniqueWellPaths.insert(fileCurve->wellPath());
uniqueWellNames.insert(fileCurve->wellName());
}
} }
if (uniqueCases.size() == 1u) if (uniqueCases.size() == 1u)
{ {
setCaseToApply(*uniqueCases.begin()); setCaseToApply(*uniqueCases.begin());
} }
else
{
setCaseToApply(nullptr);
}
if (uniqueTrajectoryTypes.size() == 1u) if (uniqueTrajectoryTypes.size() == 1u)
{ {
@ -164,44 +239,25 @@ void RimWellLogCurveCommonDataSource::updateDefaultOptions(const std::vector<Rim
{ {
setWellPathToApply(*uniqueWellPaths.begin()); setWellPathToApply(*uniqueWellPaths.begin());
} }
else if (uniqueBranchIndex.size() == 1u)
{ {
setWellPathToApply(nullptr); setBranchIndexToApply(*uniqueBranchIndex.begin());
}
if (uniqueBranchDetection.size() == 1u)
{
setBranchDetectionToApply(*uniqueBranchDetection.begin() == true ?
caf::Tristate::State::True : caf::Tristate::State::False);
} }
if (uniqueWellNames.size() == 1u) if (uniqueWellNames.size() == 1u)
{ {
m_simWellName = *uniqueWellNames.begin(); setSimWellNameToApply(*uniqueWellNames.begin());
if (uniqueBranchDetection.size() == 1u)
{
m_branchDetection.v() = *uniqueBranchDetection.begin() == true ?
caf::Tristate::State::True : caf::Tristate::State::False;
}
else
{
m_branchDetection.v() = caf::Tristate::State::PartiallyTrue;
}
} }
else
{
m_simWellName = QString("");
}
}
else
{
setWellPathToApply(nullptr);
m_simWellName = QString("");
} }
if (uniqueTimeSteps.size() == 1u) if (uniqueTimeSteps.size() == 1u)
{ {
setTimeStepToApply(*uniqueTimeSteps.begin()); setTimeStepToApply(*uniqueTimeSteps.begin());
} }
else
{
setTimeStepToApply(-1);
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -460,11 +516,11 @@ void RimWellLogCurveCommonDataSource::defineUiOrdering(QString uiConfigName, caf
if (eclipseCase) if (eclipseCase)
{ {
group->add(&m_trajectoryType); group->add(&m_trajectoryType);
if (m_trajectoryType() == RimWellLogExtractionCurve::WELL_PATH) if (trajectoryTypeToApply() == RimWellLogExtractionCurve::WELL_PATH)
{ {
group->add(&m_wellPath); group->add(&m_wellPath);
} }
else else if (trajectoryTypeToApply() == RimWellLogExtractionCurve::SIMULATION_WELL)
{ {
group->add(&m_simWellName); group->add(&m_simWellName);
if (RiaSimWellBranchTools::simulationWellBranches(m_simWellName(), true).size() > 1) if (RiaSimWellBranchTools::simulationWellBranches(m_simWellName(), true).size() > 1)

View File

@ -31,8 +31,6 @@ class RimWellLogCurve;
class RimWellLogPlot; class RimWellLogPlot;
class RimWellPath; class RimWellPath;
//================================================================================================== //==================================================================================================
/// ///
//================================================================================================== //==================================================================================================
@ -45,11 +43,20 @@ public:
RimCase* caseToApply() const; RimCase* caseToApply() const;
void setCaseToApply(RimCase* val); void setCaseToApply(RimCase* val);
int trajectoryTypeToApply() const;
void setTrajectoryTypeToApply(int val);
RimWellPath* wellPathToApply() const; RimWellPath* wellPathToApply() const;
void setWellPathToApply(RimWellPath* val); void setWellPathToApply(RimWellPath* val);
int branchIndexToApply() const;
void setBranchIndexToApply(int val);
caf::Tristate branchDetectionToApply() const;
void setBranchDetectionToApply(caf::Tristate::State val);
QString simWellNameToApply() const; QString simWellNameToApply() const;
void setSimWellNameToApply(const QString& val);
int timeStepToApply() const; int timeStepToApply() const;
void setTimeStepToApply(int val); void setTimeStepToApply(int val);
void resetDefaultOptions();
void updateDefaultOptions(const std::vector<RimWellLogCurve*>& curves); void updateDefaultOptions(const std::vector<RimWellLogCurve*>& curves);
void updateDefaultOptions(); void updateDefaultOptions();
void updateCurves(std::vector<RimWellLogCurve*>& curves); void updateCurves(std::vector<RimWellLogCurve*>& curves);