More work on setting default values when creating new well log plots

This commit is contained in:
Gaute Lindkvist 2019-09-11 15:54:59 +02:00
parent 96fc311668
commit 460fbb6b9c
9 changed files with 147 additions and 127 deletions

View File

@ -280,7 +280,7 @@ void RicNewWellBoreStabilityPlotFeature::createAnglesTrack( RimWellBoreStability
curve->loadDataAndUpdate( false ); curve->loadDataAndUpdate( false );
double actualMinValue = minValue, actualMaxValue = maxValue; double actualMinValue = minValue, actualMaxValue = maxValue;
curve->valueRange( &actualMinValue, &actualMaxValue ); curve->xValueRangeInQwt( &actualMinValue, &actualMaxValue );
while ( maxValue < actualMaxValue ) while ( maxValue < actualMaxValue )
{ {
maxValue += angleIncrement; maxValue += angleIncrement;

View File

@ -25,6 +25,7 @@
#include "RimProject.h" #include "RimProject.h"
#include "RimWellLogCurve.h" #include "RimWellLogCurve.h"
#include "RimWellLogExtractionCurve.h"
#include "RimWellLogPlot.h" #include "RimWellLogPlot.h"
#include "RimWellLogTrack.h" #include "RimWellLogTrack.h"
@ -51,8 +52,9 @@ bool RicNewWellLogPlotFeature::isCommandEnabled()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicNewWellLogPlotFeature::onActionTriggered( bool isChecked ) void RicNewWellLogPlotFeature::onActionTriggered( bool isChecked )
{ {
RimWellLogTrack* plotTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack(); RimWellLogTrack* plotTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack();
RicWellLogTools::addExtractionCurve( plotTrack, nullptr, nullptr, nullptr, -1, true ); RimWellLogExtractionCurve* curve = RicWellLogTools::addExtractionCurve( plotTrack, nullptr, nullptr, nullptr, -1, true );
curve->loadDataAndUpdate( true );
RimWellLogPlot* plot = nullptr; RimWellLogPlot* plot = nullptr;
plotTrack->firstAncestorOrThisOfTypeAsserted( plot ); plotTrack->firstAncestorOrThisOfTypeAsserted( plot );
plot->zoomAll(); plot->zoomAll();

View File

@ -649,7 +649,7 @@ void RimPlotCurve::loadDataAndUpdate( bool updateParentPlot )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RimPlotCurve::xValueRange( double* minimumValue, double* maximumValue ) const bool RimPlotCurve::xValueRangeInQwt( double* minimumValue, double* maximumValue ) const
{ {
CVF_ASSERT( minimumValue && maximumValue ); CVF_ASSERT( minimumValue && maximumValue );
CVF_ASSERT( m_qwtPlotCurve ); CVF_ASSERT( m_qwtPlotCurve );
@ -668,7 +668,7 @@ bool RimPlotCurve::xValueRange( double* minimumValue, double* maximumValue ) con
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RimPlotCurve::yValueRange( double* minimumValue, double* maximumValue ) const bool RimPlotCurve::yValueRangeInQwt( double* minimumValue, double* maximumValue ) const
{ {
CVF_ASSERT( minimumValue && maximumValue ); CVF_ASSERT( minimumValue && maximumValue );
CVF_ASSERT( m_qwtPlotCurve ); CVF_ASSERT( m_qwtPlotCurve );

View File

@ -50,8 +50,8 @@ public:
void loadDataAndUpdate( bool updateParentPlot ); void loadDataAndUpdate( bool updateParentPlot );
virtual bool xValueRange( double* minimumValue, double* maximumValue ) const; virtual bool xValueRangeInQwt( double* minimumValue, double* maximumValue ) const;
virtual bool yValueRange( double* minimumValue, double* maximumValue ) const; virtual bool yValueRangeInQwt( double* minimumValue, double* maximumValue ) const;
void setParentQwtPlotAndReplot( QwtPlot* plot ); void setParentQwtPlotAndReplot( QwtPlot* plot );
void setParentQwtPlotNoReplot( QwtPlot* plot ); void setParentQwtPlotNoReplot( QwtPlot* plot );

View File

@ -33,6 +33,8 @@
#include "qwt_symbol.h" #include "qwt_symbol.h"
#include <algorithm>
// NB! Special macro for pure virtual class // NB! Special macro for pure virtual class
CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimWellLogCurve, "WellLogPlotCurve" ); CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimWellLogCurve, "WellLogPlotCurve" );
@ -55,9 +57,16 @@ RimWellLogCurve::~RimWellLogCurve() {}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RimWellLogCurve::valueRange( double* minimumValue, double* maximumValue ) const bool RimWellLogCurve::xValueRangeInData( double* minimumValue, double* maximumValue ) const
{ {
return xValueRange( minimumValue, maximumValue ); if ( m_curveData->xValues().empty() )
{
return false;
}
auto minMaxIteratorPair = std::minmax_element( m_curveData->xValues().begin(), m_curveData->xValues().end() );
*minimumValue = *( minMaxIteratorPair.first );
*maximumValue = *( minMaxIteratorPair.second );
return true;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -38,7 +38,7 @@ public:
RimWellLogCurve(); RimWellLogCurve();
~RimWellLogCurve() override; ~RimWellLogCurve() override;
bool valueRange( double* minimumValue, double* maximumValue ) const; bool xValueRangeInData( double* minimumValue, double* maximumValue ) const;
const RigWellLogCurveData* curveData() const; const RigWellLogCurveData* curveData() const;

View File

@ -225,7 +225,7 @@ void RimWellLogExtractionCurve::setPropertiesFromView( Rim3dView* view )
} }
else if ( geomCase ) else if ( geomCase )
{ {
m_geomResultDefinition->setResultAddress( RigFemResultAddress( RIG_NODAL, "POR", "" ) ); m_geomResultDefinition->setResultAddress( RigFemResultAddress( RIG_ELEMENT, "POR", "" ) );
} }
clearGeneratedSimWellPaths(); clearGeneratedSimWellPaths();
@ -332,123 +332,10 @@ void RimWellLogExtractionCurve::fieldChangedByUi( const caf::PdmFieldHandle* cha
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellLogExtractionCurve::onLoadDataAndUpdate( bool updateParentPlot ) void RimWellLogExtractionCurve::onLoadDataAndUpdate( bool updateParentPlot )
{ {
this->RimPlotCurve::updateCurvePresentation( updateParentPlot );
if ( isCurveVisible() ) if ( isCurveVisible() )
{ {
// Make sure we have set correct case data into the result definitions.
bool isUsingPseudoLength = false; bool isUsingPseudoLength = false;
extractData( &isUsingPseudoLength );
RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>( m_case.value() );
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>( m_case.value() );
m_eclipseResultDefinition->setEclipseCase( eclipseCase );
m_geomResultDefinition->setGeoMechCase( geomCase );
clampBranchIndex();
RimMainPlotCollection* mainPlotCollection;
this->firstAncestorOrThisOfTypeAsserted( mainPlotCollection );
RimWellLogPlotCollection* wellLogCollection = mainPlotCollection->wellLogPlotCollection();
cvf::ref<RigEclipseWellLogExtractor> eclExtractor;
if ( eclipseCase )
{
if ( m_trajectoryType == WELL_PATH )
{
eclExtractor = wellLogCollection->findOrCreateExtractor( m_wellPath, eclipseCase );
}
else
{
std::vector<const RigWellPath*> simWellBranches =
RiaSimWellBranchTools::simulationWellBranches( m_simWellName, m_branchDetection );
if ( m_branchIndex >= 0 && m_branchIndex < static_cast<int>( simWellBranches.size() ) )
{
auto wellBranch = simWellBranches[m_branchIndex];
eclExtractor = wellLogCollection->findOrCreateSimWellExtractor( m_simWellName,
eclipseCase->caseUserDescription(),
wellBranch,
eclipseCase->eclipseCaseData() );
if ( eclExtractor.notNull() )
{
m_wellPathsWithExtractors.push_back( wellBranch );
}
isUsingPseudoLength = true;
}
}
}
cvf::ref<RigGeoMechWellLogExtractor> geomExtractor = wellLogCollection->findOrCreateExtractor( m_wellPath,
geomCase );
std::vector<double> values;
std::vector<double> measuredDepthValues;
std::vector<double> tvDepthValues;
RiaDefines::DepthUnitType depthUnit = RiaDefines::UNIT_METER;
if ( eclExtractor.notNull() && eclipseCase )
{
measuredDepthValues = eclExtractor->cellIntersectionMDs();
tvDepthValues = eclExtractor->cellIntersectionTVDs();
m_eclipseResultDefinition->loadResult();
cvf::ref<RigResultAccessor> resAcc =
RigResultAccessorFactory::createFromResultDefinition( eclipseCase->eclipseCaseData(),
0,
m_timeStep,
m_eclipseResultDefinition );
if ( resAcc.notNull() )
{
eclExtractor->curveData( resAcc.p(), &values );
}
RiaEclipseUnitTools::UnitSystem eclipseUnitsType = eclipseCase->eclipseCaseData()->unitsType();
if ( eclipseUnitsType == RiaEclipseUnitTools::UNITS_FIELD )
{
// See https://github.com/OPM/ResInsight/issues/538
depthUnit = RiaDefines::UNIT_FEET;
}
}
else if ( geomExtractor.notNull() ) // geomExtractor
{
measuredDepthValues = geomExtractor->cellIntersectionMDs();
tvDepthValues = geomExtractor->cellIntersectionTVDs();
findAndLoadWbsParametersFromLasFiles( m_wellPath(), geomExtractor.p() );
RimWellBoreStabilityPlot* wbsPlot;
this->firstAncestorOrThisOfType( wbsPlot );
if ( wbsPlot )
{
geomExtractor->setWbsParameters( wbsPlot->porePressureSource(),
wbsPlot->poissonRatioSource(),
wbsPlot->ucsSource(),
wbsPlot->userDefinedPoissonRatio(),
wbsPlot->userDefinedUcs() );
}
geomExtractor->setRkbDiff( rkbDiff() );
m_geomResultDefinition->loadResult();
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 );
}
else
{
m_curveData->setValuesWithTVD( values, measuredDepthValues, tvDepthValues, depthUnit, true );
}
}
RiaDefines::DepthUnitType displayUnit = RiaDefines::UNIT_METER; RiaDefines::DepthUnitType displayUnit = RiaDefines::UNIT_METER;
@ -475,6 +362,8 @@ void RimWellLogExtractionCurve::onLoadDataAndUpdate( bool updateParentPlot )
m_qwtPlotCurve->setLineSegmentStartStopIndices( m_curveData->polylineStartStopIndices() ); m_qwtPlotCurve->setLineSegmentStartStopIndices( m_curveData->polylineStartStopIndices() );
this->RimPlotCurve::updateCurvePresentation( updateParentPlot );
if ( isUsingPseudoLength ) if ( isUsingPseudoLength )
{ {
RimWellLogTrack* wellLogTrack; RimWellLogTrack* wellLogTrack;
@ -502,6 +391,125 @@ void RimWellLogExtractionCurve::onLoadDataAndUpdate( bool updateParentPlot )
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogExtractionCurve::extractData( bool* isUsingPseudoLength )
{
CAF_ASSERT( isUsingPseudoLength );
// Make sure we have set correct case data into the result definitions.
RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>( m_case.value() );
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>( m_case.value() );
m_eclipseResultDefinition->setEclipseCase( eclipseCase );
m_geomResultDefinition->setGeoMechCase( geomCase );
clampBranchIndex();
RimMainPlotCollection* mainPlotCollection;
this->firstAncestorOrThisOfTypeAsserted( mainPlotCollection );
RimWellLogPlotCollection* wellLogCollection = mainPlotCollection->wellLogPlotCollection();
cvf::ref<RigEclipseWellLogExtractor> eclExtractor;
if ( eclipseCase )
{
if ( m_trajectoryType == WELL_PATH )
{
eclExtractor = wellLogCollection->findOrCreateExtractor( m_wellPath, eclipseCase );
}
else
{
std::vector<const RigWellPath*> simWellBranches =
RiaSimWellBranchTools::simulationWellBranches( m_simWellName, m_branchDetection );
if ( m_branchIndex >= 0 && m_branchIndex < static_cast<int>( simWellBranches.size() ) )
{
auto wellBranch = simWellBranches[m_branchIndex];
eclExtractor = wellLogCollection->findOrCreateSimWellExtractor( m_simWellName,
eclipseCase->caseUserDescription(),
wellBranch,
eclipseCase->eclipseCaseData() );
if ( eclExtractor.notNull() )
{
m_wellPathsWithExtractors.push_back( wellBranch );
}
*isUsingPseudoLength = true;
}
}
}
cvf::ref<RigGeoMechWellLogExtractor> geomExtractor = wellLogCollection->findOrCreateExtractor( m_wellPath, geomCase );
std::vector<double> values;
std::vector<double> measuredDepthValues;
std::vector<double> tvDepthValues;
RiaDefines::DepthUnitType depthUnit = RiaDefines::UNIT_METER;
if ( eclExtractor.notNull() && eclipseCase )
{
measuredDepthValues = eclExtractor->cellIntersectionMDs();
tvDepthValues = eclExtractor->cellIntersectionTVDs();
m_eclipseResultDefinition->loadResult();
cvf::ref<RigResultAccessor> resAcc =
RigResultAccessorFactory::createFromResultDefinition( eclipseCase->eclipseCaseData(),
0,
m_timeStep,
m_eclipseResultDefinition );
if ( resAcc.notNull() )
{
eclExtractor->curveData( resAcc.p(), &values );
}
RiaEclipseUnitTools::UnitSystem eclipseUnitsType = eclipseCase->eclipseCaseData()->unitsType();
if ( eclipseUnitsType == RiaEclipseUnitTools::UNITS_FIELD )
{
// See https://github.com/OPM/ResInsight/issues/538
depthUnit = RiaDefines::UNIT_FEET;
}
}
else if ( geomExtractor.notNull() ) // geomExtractor
{
measuredDepthValues = geomExtractor->cellIntersectionMDs();
tvDepthValues = geomExtractor->cellIntersectionTVDs();
findAndLoadWbsParametersFromLasFiles( m_wellPath(), geomExtractor.p() );
RimWellBoreStabilityPlot* wbsPlot;
this->firstAncestorOrThisOfType( wbsPlot );
if ( wbsPlot )
{
geomExtractor->setWbsParameters( wbsPlot->porePressureSource(),
wbsPlot->poissonRatioSource(),
wbsPlot->ucsSource(),
wbsPlot->userDefinedPoissonRatio(),
wbsPlot->userDefinedUcs() );
}
geomExtractor->setRkbDiff( rkbDiff() );
m_geomResultDefinition->loadResult();
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 );
}
else
{
m_curveData->setValuesWithTVD( values, measuredDepthValues, tvDepthValues, depthUnit, true );
}
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// Search well path for LAS-files containing Well Bore Stability data and set them in the extractor. /// Search well path for LAS-files containing Well Bore Stability data and set them in the extractor.
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -89,6 +89,7 @@ public:
protected: protected:
QString createCurveAutoName() override; QString createCurveAutoName() override;
void onLoadDataAndUpdate( bool updateParentPlot ) override; void onLoadDataAndUpdate( bool updateParentPlot ) override;
void extractData( bool* isUsingPseudoLength );
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, void fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue, const QVariant& oldValue,

View File

@ -760,7 +760,7 @@ void RimWellLogTrack::availableDepthRange( double* minimumDepth, double* maximum
double minCurveDepth = HUGE_VAL; double minCurveDepth = HUGE_VAL;
double maxCurveDepth = -HUGE_VAL; double maxCurveDepth = -HUGE_VAL;
if ( curve->isCurveVisible() && curve->yValueRange( &minCurveDepth, &maxCurveDepth ) ) if ( curve->isCurveVisible() && curve->yValueRangeInQwt( &minCurveDepth, &maxCurveDepth ) )
{ {
if ( minCurveDepth < minDepth ) if ( minCurveDepth < minDepth )
{ {
@ -1175,7 +1175,7 @@ void RimWellLogTrack::calculateXZoomRange()
if ( curve->isCurveVisible() ) if ( curve->isCurveVisible() )
{ {
visibleCurves++; visibleCurves++;
if ( curve->xValueRange( &minCurveValue, &maxCurveValue ) ) if ( curve->xValueRangeInData( &minCurveValue, &maxCurveValue ) )
{ {
if ( minCurveValue < minValue ) if ( minCurveValue < minValue )
{ {