#5129 Fix depth ranges when curve units don't match display units

This commit is contained in:
Gaute Lindkvist 2019-11-29 10:02:34 +01:00
parent e31f2d2b50
commit 602751dccc
6 changed files with 28 additions and 45 deletions

View File

@ -246,13 +246,16 @@ void RimWellFlowRateCurve::updateStackedPlotData()
bool isFirstTrack = ( wellLogTrack == wellLogPlot->plotByIndex( 0 ) );
RimWellLogPlot::DepthTypeEnum depthType = wellLogPlot->depthType();
RiaDefines::DepthUnitType displayUnit = RiaDefines::UNIT_NONE;
RiaDefines::DepthUnitType displayUnit = wellLogPlot->depthUnit();
if ( depthType == RiaDefines::CONNECTION_NUMBER )
{
displayUnit = RiaDefines::UNIT_NONE;
}
std::vector<double> depthValues;
std::vector<double> stackedValues;
std::vector<std::pair<size_t, size_t>> polyLineStartStopIndices;
double zPos = -10000.0 +
100 * groupId(); // Z-position of curve, to draw them in correct order hiding the things behind
double zPos = -10000.0 + 100 * groupId(); // Z-position of curve, to draw them in correct order
// Starting way behind the grid (z == 0) at -10000 giving room for 100 groups with 100 curves each before getting above the grid
{
std::map<int, std::vector<RimWellFlowRateCurve*>> stackedCurveGroups = wellLogTrack->visibleStackedCurves();
@ -284,7 +287,7 @@ void RimWellFlowRateCurve::updateStackedPlotData()
}
RigWellLogCurveData tempCurveData;
tempCurveData.setValuesAndDepths( allStackedValues, allDepthValues, depthType, RiaDefines::UNIT_NONE, false );
tempCurveData.setValuesAndDepths( allStackedValues, allDepthValues, depthType, displayUnit, false );
depthValues = tempCurveData.depthPlotValues( depthType, displayUnit );
stackedValues = tempCurveData.xPlotValues();

View File

@ -99,22 +99,10 @@ bool RimWellLogCurve::yValueRangeInData( double* minimumValue, double* maximumVa
RimWellLogPlot* wellLogPlot = nullptr;
firstAncestorOrThisOfTypeAsserted( wellLogPlot );
auto depthType = wellLogPlot->depthType();
auto displayUnit = wellLogPlot->depthUnit();
auto depthRangeIt = m_curveDataDepthRange.find( wellLogPlot->depthType() );
if ( depthRangeIt == m_curveDataDepthRange.end() )
{
return false;
}
if ( depthRangeIt->second.first == -std::numeric_limits<double>::infinity() ||
depthRangeIt->second.second == std::numeric_limits<double>::infinity() )
{
return false;
}
*minimumValue = depthRangeIt->second.first;
*maximumValue = depthRangeIt->second.second;
return true;
return m_curveData->calculateDepthRange( depthType, displayUnit, minimumValue, maximumValue );
}
//--------------------------------------------------------------------------------------------------
@ -127,7 +115,7 @@ void RimWellLogCurve::setValuesAndDepths( const std::vector<double>& xValues,
bool isExtractionCurve )
{
m_curveData->setValuesAndDepths( xValues, measuredDepths, depthType, depthUnit, isExtractionCurve );
calculateCurveDataRanges();
calculateCurveDataXRange();
}
//--------------------------------------------------------------------------------------------------
@ -139,7 +127,7 @@ void RimWellLogCurve::setValuesAndDepths( const std::vector<double>&
bool isExtractionCurve )
{
m_curveData->setValuesAndDepths( xValues, depths, depthUnit, isExtractionCurve );
calculateCurveDataRanges();
calculateCurveDataXRange();
}
//--------------------------------------------------------------------------------------------------
@ -202,22 +190,11 @@ void RimWellLogCurve::setOverrideCurveDataXRange( double minimumValue, double ma
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogCurve::calculateCurveDataRanges()
void RimWellLogCurve::calculateCurveDataXRange()
{
// Invalidate range first
m_curveDataXRange = std::make_pair( std::numeric_limits<double>::infinity(),
-std::numeric_limits<double>::infinity() );
for ( auto depthType : m_curveData->availableDepthTypes() )
{
m_curveDataDepthRange[depthType] = std::make_pair( std::numeric_limits<double>::infinity(),
-std::numeric_limits<double>::infinity() );
m_curveData->calculateDepthRange( depthType,
&m_curveDataDepthRange[depthType].first,
&m_curveDataDepthRange[depthType].second );
}
for ( double xValue : m_curveData->xValues() )
{
if ( RiaCurveDataTools::isValidValue( xValue, false ) )

View File

@ -70,12 +70,9 @@ protected:
void updateZoomInParentPlot() override;
void updateLegendsInPlot() override;
void setOverrideCurveDataXRange( double minimumValue, double maximumValue );
void calculateCurveDataXRange();
private:
void calculateCurveDataRanges();
private:
cvf::ref<RigWellLogCurveData> m_curveData;
std::pair<double, double> m_curveDataXRange;
std::map<RiaDefines::DepthTypeEnum, std::pair<double, double>> m_curveDataDepthRange;
cvf::ref<RigWellLogCurveData> m_curveData;
std::pair<double, double> m_curveDataXRange;
};

View File

@ -251,7 +251,7 @@ public:
double minDepth = 0.0;
double maxDepth = 0.0;
firstCurveData->calculateDepthRange( RiaDefines::MEASURED_DEPTH, &minDepth, &maxDepth );
firstCurveData->calculateDepthRange( RiaDefines::MEASURED_DEPTH, firstCurveData->depthUnit(), &minDepth, &maxDepth );
lasFile->setStartDepth( minDepth );
lasFile->setStopDepth( maxDepth );

View File

@ -326,6 +326,7 @@ void RigWellLogCurveData::splitIntervalAtEmptySpace( const std::vector<double>&
///
//--------------------------------------------------------------------------------------------------
bool RigWellLogCurveData::calculateDepthRange( RiaDefines::DepthTypeEnum depthType,
RiaDefines::DepthUnitType depthUnit,
double* minimumDepth,
double* maximumDepth ) const
{
@ -334,9 +335,10 @@ bool RigWellLogCurveData::calculateDepthRange( RiaDefines::DepthTypeEnum depthTy
double minValue = HUGE_VAL;
double maxValue = -HUGE_VAL;
for ( size_t vIdx = 0; vIdx < depths( depthType ).size(); vIdx++ )
std::vector<double> depthValues = depthPlotValues( depthType, depthUnit );
for ( size_t vIdx = 0; vIdx < depthValues.size(); vIdx++ )
{
double value = depths( depthType )[vIdx];
double value = depthValues[vIdx];
if ( value < minValue )
{
@ -406,12 +408,13 @@ std::vector<double> RigWellLogCurveData::convertDepthValues( RiaDefines::DepthUn
{
CVF_ASSERT( destinationDepthUnit != m_depthUnit );
if ( destinationDepthUnit == RiaDefines::UNIT_METER )
if ( destinationDepthUnit == RiaDefines::UNIT_METER && m_depthUnit == RiaDefines::UNIT_FEET )
{
return convertFromFeetToMeter( values );
}
else
else if ( destinationDepthUnit == RiaDefines::UNIT_FEET && m_depthUnit == RiaDefines::UNIT_METER )
{
return convertFromMeterToFeet( values );
}
return values;
}

View File

@ -54,7 +54,10 @@ public:
std::set<RiaDefines::DepthTypeEnum> availableDepthTypes() const;
bool calculateDepthRange( RiaDefines::DepthTypeEnum depthType, double* minMD, double* maxMD ) const;
bool calculateDepthRange( RiaDefines::DepthTypeEnum depthType,
RiaDefines::DepthUnitType depthUnit,
double* minMD,
double* maxMD ) const;
RiaDefines::DepthUnitType depthUnit() const;