diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp index 885a8fe57f..0d5b74c3bf 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp @@ -280,7 +280,7 @@ void RicNewWellBoreStabilityPlotFeature::createAnglesTrack( RimWellBoreStability curve->loadDataAndUpdate( false ); double actualMinValue = minValue, actualMaxValue = maxValue; - curve->valueRange( &actualMinValue, &actualMaxValue ); + curve->xValueRangeInQwt( &actualMinValue, &actualMaxValue ); while ( maxValue < actualMaxValue ) { maxValue += angleIncrement; diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotFeature.cpp index a39f979b10..312724d077 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotFeature.cpp @@ -25,6 +25,7 @@ #include "RimProject.h" #include "RimWellLogCurve.h" +#include "RimWellLogExtractionCurve.h" #include "RimWellLogPlot.h" #include "RimWellLogTrack.h" @@ -51,8 +52,9 @@ bool RicNewWellLogPlotFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicNewWellLogPlotFeature::onActionTriggered( bool isChecked ) { - RimWellLogTrack* plotTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack(); - RicWellLogTools::addExtractionCurve( plotTrack, nullptr, nullptr, nullptr, -1, true ); + RimWellLogTrack* plotTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack(); + RimWellLogExtractionCurve* curve = RicWellLogTools::addExtractionCurve( plotTrack, nullptr, nullptr, nullptr, -1, true ); + curve->loadDataAndUpdate( true ); RimWellLogPlot* plot = nullptr; plotTrack->firstAncestorOrThisOfTypeAsserted( plot ); plot->zoomAll(); diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp index 43ea70372f..14cbf83229 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp @@ -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( 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( m_qwtPlotCurve ); diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.h b/ApplicationCode/ProjectDataModel/RimPlotCurve.h index 3a87bd617e..d17a720bb7 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.h +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.h @@ -50,8 +50,8 @@ public: void loadDataAndUpdate( bool updateParentPlot ); - virtual bool xValueRange( double* minimumValue, double* maximumValue ) const; - virtual bool yValueRange( double* minimumValue, double* maximumValue ) const; + virtual bool xValueRangeInQwt( double* minimumValue, double* maximumValue ) const; + virtual bool yValueRangeInQwt( double* minimumValue, double* maximumValue ) const; void setParentQwtPlotAndReplot( QwtPlot* plot ); void setParentQwtPlotNoReplot( QwtPlot* plot ); diff --git a/ApplicationCode/ProjectDataModel/RimWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogCurve.cpp index 5567c43ef7..6e0fbcf327 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogCurve.cpp @@ -33,6 +33,8 @@ #include "qwt_symbol.h" +#include + // NB! Special macro for pure virtual class 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; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellLogCurve.h b/ApplicationCode/ProjectDataModel/RimWellLogCurve.h index d2de65a34a..0178f5d361 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogCurve.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogCurve.h @@ -38,7 +38,7 @@ public: RimWellLogCurve(); ~RimWellLogCurve() override; - bool valueRange( double* minimumValue, double* maximumValue ) const; + bool xValueRangeInData( double* minimumValue, double* maximumValue ) const; const RigWellLogCurveData* curveData() const; diff --git a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp index 43cab38980..34b3749d41 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp @@ -225,7 +225,7 @@ void RimWellLogExtractionCurve::setPropertiesFromView( Rim3dView* view ) } else if ( geomCase ) { - m_geomResultDefinition->setResultAddress( RigFemResultAddress( RIG_NODAL, "POR", "" ) ); + m_geomResultDefinition->setResultAddress( RigFemResultAddress( RIG_ELEMENT, "POR", "" ) ); } clearGeneratedSimWellPaths(); @@ -332,123 +332,10 @@ void RimWellLogExtractionCurve::fieldChangedByUi( const caf::PdmFieldHandle* cha //-------------------------------------------------------------------------------------------------- void RimWellLogExtractionCurve::onLoadDataAndUpdate( bool updateParentPlot ) { - this->RimPlotCurve::updateCurvePresentation( updateParentPlot ); - if ( isCurveVisible() ) { - // Make sure we have set correct case data into the result definitions. bool isUsingPseudoLength = false; - - RimGeoMechCase* geomCase = dynamic_cast( m_case.value() ); - RimEclipseCase* eclipseCase = dynamic_cast( m_case.value() ); - m_eclipseResultDefinition->setEclipseCase( eclipseCase ); - m_geomResultDefinition->setGeoMechCase( geomCase ); - - clampBranchIndex(); - - RimMainPlotCollection* mainPlotCollection; - this->firstAncestorOrThisOfTypeAsserted( mainPlotCollection ); - - RimWellLogPlotCollection* wellLogCollection = mainPlotCollection->wellLogPlotCollection(); - - cvf::ref eclExtractor; - - if ( eclipseCase ) - { - if ( m_trajectoryType == WELL_PATH ) - { - eclExtractor = wellLogCollection->findOrCreateExtractor( m_wellPath, eclipseCase ); - } - else - { - std::vector simWellBranches = - RiaSimWellBranchTools::simulationWellBranches( m_simWellName, m_branchDetection ); - if ( m_branchIndex >= 0 && m_branchIndex < static_cast( 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 geomExtractor = wellLogCollection->findOrCreateExtractor( m_wellPath, - geomCase ); - - std::vector values; - std::vector measuredDepthValues; - std::vector tvDepthValues; - - RiaDefines::DepthUnitType depthUnit = RiaDefines::UNIT_METER; - - if ( eclExtractor.notNull() && eclipseCase ) - { - measuredDepthValues = eclExtractor->cellIntersectionMDs(); - tvDepthValues = eclExtractor->cellIntersectionTVDs(); - - m_eclipseResultDefinition->loadResult(); - - cvf::ref 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 ); - } - } + extractData( &isUsingPseudoLength ); RiaDefines::DepthUnitType displayUnit = RiaDefines::UNIT_METER; @@ -475,6 +362,8 @@ void RimWellLogExtractionCurve::onLoadDataAndUpdate( bool updateParentPlot ) m_qwtPlotCurve->setLineSegmentStartStopIndices( m_curveData->polylineStartStopIndices() ); + this->RimPlotCurve::updateCurvePresentation( updateParentPlot ); + if ( isUsingPseudoLength ) { 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( m_case.value() ); + RimEclipseCase* eclipseCase = dynamic_cast( m_case.value() ); + m_eclipseResultDefinition->setEclipseCase( eclipseCase ); + m_geomResultDefinition->setGeoMechCase( geomCase ); + + clampBranchIndex(); + + RimMainPlotCollection* mainPlotCollection; + this->firstAncestorOrThisOfTypeAsserted( mainPlotCollection ); + + RimWellLogPlotCollection* wellLogCollection = mainPlotCollection->wellLogPlotCollection(); + + cvf::ref eclExtractor; + + if ( eclipseCase ) + { + if ( m_trajectoryType == WELL_PATH ) + { + eclExtractor = wellLogCollection->findOrCreateExtractor( m_wellPath, eclipseCase ); + } + else + { + std::vector simWellBranches = + RiaSimWellBranchTools::simulationWellBranches( m_simWellName, m_branchDetection ); + if ( m_branchIndex >= 0 && m_branchIndex < static_cast( 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 geomExtractor = wellLogCollection->findOrCreateExtractor( m_wellPath, geomCase ); + + std::vector values; + std::vector measuredDepthValues; + std::vector tvDepthValues; + + RiaDefines::DepthUnitType depthUnit = RiaDefines::UNIT_METER; + + if ( eclExtractor.notNull() && eclipseCase ) + { + measuredDepthValues = eclExtractor->cellIntersectionMDs(); + tvDepthValues = eclExtractor->cellIntersectionTVDs(); + + m_eclipseResultDefinition->loadResult(); + + cvf::ref 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. //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.h b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.h index a051e57d43..fe4ca19f6c 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.h @@ -89,6 +89,7 @@ public: protected: QString createCurveAutoName() override; void onLoadDataAndUpdate( bool updateParentPlot ) override; + void extractData( bool* isUsingPseudoLength ); void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, diff --git a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp index c55a45ea5e..2d1082b686 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp @@ -760,7 +760,7 @@ void RimWellLogTrack::availableDepthRange( double* minimumDepth, double* maximum double minCurveDepth = HUGE_VAL; double maxCurveDepth = -HUGE_VAL; - if ( curve->isCurveVisible() && curve->yValueRange( &minCurveDepth, &maxCurveDepth ) ) + if ( curve->isCurveVisible() && curve->yValueRangeInQwt( &minCurveDepth, &maxCurveDepth ) ) { if ( minCurveDepth < minDepth ) { @@ -1175,7 +1175,7 @@ void RimWellLogTrack::calculateXZoomRange() if ( curve->isCurveVisible() ) { visibleCurves++; - if ( curve->xValueRange( &minCurveValue, &maxCurveValue ) ) + if ( curve->xValueRangeInData( &minCurveValue, &maxCurveValue ) ) { if ( minCurveValue < minValue ) {