#4792 Fix xValue range for Well Allocation Plots

This commit is contained in:
Gaute Lindkvist 2019-09-30 09:48:05 +02:00
parent 2daa4dea93
commit f2eac1e2ec
6 changed files with 121 additions and 58 deletions

View File

@ -236,7 +236,7 @@ void RimWellFlowRateCurve::updateStackedPlotData()
stackedCurves = stackedCurveGroups[groupId()];
}
std::vector<double> allDepthValues = m_curveData->measuredDepths();
std::vector<double> allDepthValues = curveData()->measuredDepths();
std::vector<double> allStackedValues( allDepthValues.size() );
for ( RimWellFlowRateCurve* stCurve : stackedCurves )
@ -305,6 +305,9 @@ void RimWellFlowRateCurve::updateStackedPlotData()
polyLineStartStopIndices.front().second += 1;
}
auto minmax_it = std::minmax_element( stackedValues.begin(), stackedValues.end() );
this->setOverrideCurveDataXRange( *( minmax_it.first ), *( minmax_it.second ) );
m_qwtPlotCurve->setSamples( stackedValues.data(), depthValues.data(), static_cast<int>( depthValues.size() ) );
m_qwtPlotCurve->setLineSegmentStartStopIndices( polyLineStartStopIndices );
@ -344,9 +347,7 @@ void RimWellFlowRateCurve::setFlowValuesPrDepthValue( const QString&
const std::vector<double>& depthValues,
const std::vector<double>& flowRates )
{
m_curveData = new RigWellLogCurveData;
m_curveData->setValuesAndMD( flowRates, depthValues, RiaDefines::UNIT_NONE, false );
this->setValuesAndMD( flowRates, depthValues, RiaDefines::UNIT_NONE, false );
m_curveAutoName = curveName;
}

View File

@ -49,6 +49,10 @@ RimWellLogCurve::RimWellLogCurve()
m_qwtPlotCurve->setXAxis( QwtPlot::xTop );
m_qwtPlotCurve->setErrorBarsXAxis( QwtPlot::xTop );
m_qwtPlotCurve->setYAxis( QwtPlot::yLeft );
m_curveData = new RigWellLogCurveData;
m_curveDataXRange = std::make_pair( std::numeric_limits<double>::infinity(),
-std::numeric_limits<double>::infinity() );
}
//--------------------------------------------------------------------------------------------------
@ -67,25 +71,44 @@ bool RimWellLogCurve::xValueRangeInData( double* minimumValue, double* maximumVa
{
return false;
}
if ( m_curveData->xValues().empty() )
if ( m_curveDataXRange.first == -std::numeric_limits<double>::infinity() ||
m_curveDataXRange.second == std::numeric_limits<double>::infinity() )
{
return false;
}
*minimumValue = std::numeric_limits<double>::infinity();
*maximumValue = -std::numeric_limits<double>::infinity();
*minimumValue = m_curveDataXRange.first;
*maximumValue = m_curveDataXRange.second;
for ( double xValue : m_curveData->xValues() )
{
if ( RiaCurveDataTools::isValidValue( xValue, false ) )
{
*minimumValue = std::min( *minimumValue, xValue );
*maximumValue = std::max( *maximumValue, xValue );
}
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogCurve::setValuesAndMD( const std::vector<double>& xValues,
const std::vector<double>& measuredDepths,
RiaDefines::DepthUnitType depthUnit,
bool isExtractionCurve )
{
m_curveData->setValuesAndMD( xValues, measuredDepths, depthUnit, isExtractionCurve );
calculateCurveDataXRange();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogCurve::setValuesWithTVD( const std::vector<double>& xValues,
const std::vector<double>& measuredDepths,
const std::vector<double>& tvDepths,
RiaDefines::DepthUnitType depthUnit,
bool isExtractionCurve )
{
m_curveData->setValuesWithTVD( xValues, measuredDepths, tvDepths, depthUnit, isExtractionCurve );
calculateCurveDataXRange();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -127,3 +150,30 @@ void RimWellLogCurve::updateLegendsInPlot()
wellLogTrack->updateAllLegendItems();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogCurve::setOverrideCurveDataXRange( double minimumValue, double maximumValue )
{
m_curveDataXRange = std::make_pair( minimumValue, maximumValue );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogCurve::calculateCurveDataXRange()
{
// Invalidate range first
m_curveDataXRange = std::make_pair( std::numeric_limits<double>::infinity(),
-std::numeric_limits<double>::infinity() );
for ( double xValue : m_curveData->xValues() )
{
if ( RiaCurveDataTools::isValidValue( xValue, false ) )
{
m_curveDataXRange.first = std::min( m_curveDataXRange.first, xValue );
m_curveDataXRange.second = std::max( m_curveDataXRange.second, xValue );
}
}
}

View File

@ -19,6 +19,7 @@
#pragma once
#include "RiaDefines.h"
#include "RimPlotCurve.h"
#include "cvfObject.h"
@ -40,6 +41,17 @@ public:
bool xValueRangeInData( double* minimumValue, double* maximumValue ) const;
void setValuesAndMD( const std::vector<double>& xValues,
const std::vector<double>& measuredDepths,
RiaDefines::DepthUnitType depthUnit,
bool isExtractionCurve );
void setValuesWithTVD( const std::vector<double>& xValues,
const std::vector<double>& measuredDepths,
const std::vector<double>& tvDepths,
RiaDefines::DepthUnitType depthUnit,
bool isExtractionCurve );
const RigWellLogCurveData* curveData() const;
virtual QString wellName() const = 0;
@ -52,7 +64,12 @@ public:
protected:
void updateZoomInParentPlot() override;
void updateLegendsInPlot() override;
void setOverrideCurveDataXRange( double minimumValue, double maximumValue );
protected:
private:
void calculateCurveDataXRange();
private:
cvf::ref<RigWellLogCurveData> m_curveData;
std::pair<double, double> m_curveDataXRange;
};

View File

@ -349,19 +349,19 @@ void RimWellLogExtractionCurve::onLoadDataAndUpdate( bool updateParentPlot )
if ( wellLogPlot->depthType() == RimWellLogPlot::TRUE_VERTICAL_DEPTH )
{
m_qwtPlotCurve->setSamples( m_curveData->xPlotValues().data(),
m_curveData->trueDepthPlotValues( displayUnit ).data(),
static_cast<int>( m_curveData->xPlotValues().size() ) );
m_qwtPlotCurve->setSamples( curveData()->xPlotValues().data(),
curveData()->trueDepthPlotValues( displayUnit ).data(),
static_cast<int>( curveData()->xPlotValues().size() ) );
isUsingPseudoLength = false;
}
else if ( wellLogPlot->depthType() == RimWellLogPlot::MEASURED_DEPTH )
{
m_qwtPlotCurve->setSamples( m_curveData->xPlotValues().data(),
m_curveData->measuredDepthPlotValues( displayUnit ).data(),
static_cast<int>( m_curveData->xPlotValues().size() ) );
m_qwtPlotCurve->setSamples( curveData()->xPlotValues().data(),
curveData()->measuredDepthPlotValues( displayUnit ).data(),
static_cast<int>( curveData()->xPlotValues().size() ) );
}
m_qwtPlotCurve->setLineSegmentStartStopIndices( m_curveData->polylineStartStopIndices() );
m_qwtPlotCurve->setLineSegmentStartStopIndices( curveData()->polylineStartStopIndices() );
this->RimPlotCurve::updateCurvePresentation( updateParentPlot );
@ -497,16 +497,15 @@ void RimWellLogExtractionCurve::extractData( bool* isUsingPseudoLength )
geomExtractor->curveData( m_geomResultDefinition->resultAddress(), m_timeStep, &values );
}
m_curveData = new RigWellLogCurveData;
if ( values.size() && measuredDepthValues.size() )
{
if ( !tvDepthValues.size() )
{
m_curveData->setValuesAndMD( values, measuredDepthValues, depthUnit, true );
this->setValuesAndMD( values, measuredDepthValues, depthUnit, true );
}
else
{
m_curveData->setValuesWithTVD( values, measuredDepthValues, tvDepthValues, depthUnit, true );
this->setValuesWithTVD( values, measuredDepthValues, tvDepthValues, depthUnit, true );
}
}
}

View File

@ -77,8 +77,6 @@ void RimWellLogFileCurve::onLoadDataAndUpdate( bool updateParentPlot )
if ( isCurveVisible() )
{
m_curveData = new RigWellLogCurveData;
RimWellLogPlot* wellLogPlot;
firstAncestorOrThisOfType( wellLogPlot );
CVF_ASSERT( wellLogPlot );
@ -100,7 +98,7 @@ void RimWellLogFileCurve::onLoadDataAndUpdate( bool updateParentPlot )
if ( values.size() == measuredDepthValues.size() && values.size() == tvdMslValues.size() )
{
m_curveData->setValuesWithTVD( values,
this->setValuesWithTVD( values,
measuredDepthValues,
tvdMslValues,
wellLogFile->depthUnit(),
@ -124,7 +122,7 @@ void RimWellLogFileCurve::onLoadDataAndUpdate( bool updateParentPlot )
if ( values.size() == trueVerticeldepthValues.size() &&
values.size() == measuredDepthValues.size() )
{
m_curveData->setValuesWithTVD( values,
this->setValuesWithTVD( values,
measuredDepthValues,
trueVerticeldepthValues,
wellLogFile->depthUnit(),
@ -152,7 +150,7 @@ void RimWellLogFileCurve::onLoadDataAndUpdate( bool updateParentPlot )
{
if ( values.size() == measuredDepthValues.size() )
{
m_curveData->setValuesAndMD( values, measuredDepthValues, wellLogFile->depthUnit(), false );
this->setValuesAndMD( values, measuredDepthValues, wellLogFile->depthUnit(), false );
}
}
}
@ -170,17 +168,17 @@ void RimWellLogFileCurve::onLoadDataAndUpdate( bool updateParentPlot )
}
if ( wellLogPlot && wellLogPlot->depthType() == RimWellLogPlot::TRUE_VERTICAL_DEPTH )
{
m_qwtPlotCurve->setSamples( m_curveData->xPlotValues().data(),
m_curveData->trueDepthPlotValues( displayUnit ).data(),
static_cast<int>( m_curveData->xPlotValues().size() ) );
m_qwtPlotCurve->setSamples( this->curveData()->xPlotValues().data(),
this->curveData()->trueDepthPlotValues( displayUnit ).data(),
static_cast<int>( this->curveData()->xPlotValues().size() ) );
}
else
{
m_qwtPlotCurve->setSamples( m_curveData->xPlotValues().data(),
m_curveData->measuredDepthPlotValues( displayUnit ).data(),
static_cast<int>( m_curveData->xPlotValues().size() ) );
m_qwtPlotCurve->setSamples( this->curveData()->xPlotValues().data(),
this->curveData()->measuredDepthPlotValues( displayUnit ).data(),
static_cast<int>( this->curveData()->xPlotValues().size() ) );
}
m_qwtPlotCurve->setLineSegmentStartStopIndices( m_curveData->polylineStartStopIndices() );
m_qwtPlotCurve->setLineSegmentStartStopIndices( this->curveData()->polylineStartStopIndices() );
if ( updateParentPlot )
{

View File

@ -372,8 +372,6 @@ void RimWellLogRftCurve::onLoadDataAndUpdate( bool updateParentPlot )
if ( isCurveVisible() )
{
m_curveData = new RigWellLogCurveData;
RimWellLogPlot* wellLogPlot;
firstAncestorOrThisOfType( wellLogPlot );
CVF_ASSERT( wellLogPlot );
@ -435,7 +433,7 @@ void RimWellLogRftCurve::onLoadDataAndUpdate( bool updateParentPlot )
measuredDepthVector = tvDepthVector;
}
m_curveData->setValuesWithTVD( values,
this->setValuesWithTVD( values,
measuredDepthVector,
tvDepthVector,
RiaEclipseUnitTools::depthUnit( unitSystem ),
@ -451,8 +449,8 @@ void RimWellLogRftCurve::onLoadDataAndUpdate( bool updateParentPlot )
{
m_qwtPlotCurve->showErrorBars( showErrorBarsInObservedData );
m_qwtPlotCurve->setPerPointLabels( perPointLabels );
m_qwtPlotCurve->setSamplesFromXValuesAndYValues( m_curveData->xPlotValues(),
m_curveData->measuredDepthPlotValues( displayUnit ),
m_qwtPlotCurve->setSamplesFromXValuesAndYValues( this->curveData()->xPlotValues(),
this->curveData()->measuredDepthPlotValues( displayUnit ),
errors,
false,
RiuQwtPlotCurve::ERROR_ALONG_X_AXIS );
@ -486,14 +484,14 @@ void RimWellLogRftCurve::onLoadDataAndUpdate( bool updateParentPlot )
{
m_qwtPlotCurve->showErrorBars( showErrorBarsInObservedData );
m_qwtPlotCurve->setPerPointLabels( perPointLabels );
m_qwtPlotCurve->setSamplesFromXValuesAndYValues( m_curveData->xPlotValues(),
m_curveData->trueDepthPlotValues( displayUnit ),
m_qwtPlotCurve->setSamplesFromXValuesAndYValues( this->curveData()->xPlotValues(),
this->curveData()->trueDepthPlotValues( displayUnit ),
errors,
false,
RiuQwtPlotCurve::ERROR_ALONG_X_AXIS );
}
m_qwtPlotCurve->setLineSegmentStartStopIndices( m_curveData->polylineStartStopIndices() );
m_qwtPlotCurve->setLineSegmentStartStopIndices( this->curveData()->polylineStartStopIndices() );
if ( updateParentPlot )
{