diff --git a/ApplicationCode/Commands/RicWellLogTools.cpp b/ApplicationCode/Commands/RicWellLogTools.cpp index 3be0681ea7..300b7d2864 100644 --- a/ApplicationCode/Commands/RicWellLogTools.cpp +++ b/ApplicationCode/Commands/RicWellLogTools.cpp @@ -25,6 +25,7 @@ #include "RimEclipseResultCase.h" #include "RimProject.h" #include "RimSimWellInView.h" +#include "RimWellLogCurveCommonDataSource.h" #include "RimWellLogExtractionCurve.h" #include "RimWellLogFile.h" #include "RimWellLogFileChannel.h" @@ -178,23 +179,90 @@ RimWellLogExtractionCurve* RicWellLogTools::addExtractionCurve( RimWellLogTrack* cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable( plotTrack->curveCount() ); curve->setColor( curveColor ); - if ( wellPath ) - { - curve->setWellPath( wellPath ); - plotTrack->setFormationWellPath( wellPath ); - plotTrack->setFormationTrajectoryType( RimWellLogTrack::WELL_PATH ); - } - if ( simWell ) - { - curve->setFromSimulationWellName( simWell->name(), branchIndex, useBranchDetection ); - plotTrack->setFormationSimWellName( simWell->name() ); - plotTrack->setFormationBranchIndex( branchIndex ); - plotTrack->setFormationTrajectoryType( RimWellLogTrack::SIMULATION_WELL ); - } + + RimCase* caseToApply = nullptr; + RimWellLogPlot* plot = nullptr; + plotTrack->firstAncestorOrThisOfTypeAsserted( plot ); + RimWellLogCurveCommonDataSource* commonDataSource = plot->commonDataSource(); if ( view ) { - plotTrack->setFormationCase( view->ownerCase() ); + caseToApply = view->ownerCase(); + } + else if ( commonDataSource->caseToApply() ) + { + caseToApply = commonDataSource->caseToApply(); + } + else if ( plotTrack->formationNamesCase() ) + { + caseToApply = plotTrack->formationNamesCase(); + } + else + { + std::vector allCases; + RiaApplication::instance()->project()->allCases( allCases ); + if ( !allCases.empty() ) caseToApply = allCases.front(); + } + + QString ownerSimWellName; + if ( !wellPath ) + { + if ( commonDataSource->wellPathToApply() ) + { + wellPath = commonDataSource->wellPathToApply(); + } + else if ( plotTrack->formationWellPath() ) + { + wellPath = plotTrack->formationWellPath(); + } + else + { + auto allWellPaths = RiaApplication::instance()->project()->allWellPaths(); + if ( !allWellPaths.empty() ) + { + wellPath = allWellPaths.front(); + } + } + } + if ( !simWell ) + { + RimEclipseCase* eclipseCase = dynamic_cast( caseToApply ); + if ( eclipseCase ) + { + if ( !commonDataSource->simWellNameToApply().isEmpty() ) + { + ownerSimWellName = commonDataSource->simWellNameToApply(); + } + else if ( !plotTrack->formationSimWellName().isEmpty() ) + { + ownerSimWellName = plotTrack->formationSimWellName(); + } + else + { + auto allSimWells = eclipseCase->sortedSimWellNames(); + if ( !allSimWells.empty() ) + { + ownerSimWellName = *allSimWells.begin(); + } + } + } + } + + if ( simWell || !ownerSimWellName.isEmpty() ) + { + QString simWellName = simWell ? simWell->name() : ownerSimWellName; + curve->setFromSimulationWellName( simWellName, branchIndex, useBranchDetection ); + } + + if ( wellPath ) + { + curve->setWellPath( wellPath ); + curve->setTrajectoryType( RimWellLogExtractionCurve::WELL_PATH ); + } + + if ( caseToApply ) + { + curve->setCase( caseToApply ); } curve->setPropertiesFromView( view ); @@ -212,7 +280,6 @@ RimWellLogExtractionCurve* RicWellLogTools::addExtractionCurve( RimWellLogTrack* // Make sure the summary plot window is visible RiuPlotMainWindowTools::showPlotMainWindow(); } - return curve; } diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp index 763042ec52..0d5b74c3bf 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp @@ -166,7 +166,7 @@ void RicNewWellBoreStabilityPlotFeature::createFormationTrack( RimWellBoreStabil RimWellLogTrack* formationTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack( false, "Formations", plot ); formationTrack->setFormationWellPath( wellPath ); formationTrack->setFormationCase( geoMechCase ); - formationTrack->setShowFormations( true ); + formationTrack->setShowFormations( RiuPlotAnnotationTool::COLOR_SHADING_AND_LINES ); formationTrack->setVisibleXRange( 0.0, 0.0 ); formationTrack->setWidthScaleFactor( RimWellLogTrack::NARROW_TRACK ); } @@ -182,7 +182,7 @@ void RicNewWellBoreStabilityPlotFeature::createCasingShoeTrack( RimWellBoreStabi casingShoeTrack->setWidthScaleFactor( RimWellLogTrack::NARROW_TRACK ); casingShoeTrack->setFormationWellPath( wellPath ); casingShoeTrack->setFormationCase( geoMechCase ); - casingShoeTrack->setShowFormations( true ); + casingShoeTrack->setShowFormations( RiuPlotAnnotationTool::DARK_LINES ); casingShoeTrack->setShowFormationLabels( false ); casingShoeTrack->setShowWellPathAttributes( true ); casingShoeTrack->setWellPathAttributesSource( wellPath ); @@ -207,7 +207,7 @@ void RicNewWellBoreStabilityPlotFeature::createStabilityCurvesTrack( RimWellBore stabilityCurvesTrack->setXAxisGridVisibility( RimWellLogPlot::AXIS_GRID_MAJOR_AND_MINOR ); stabilityCurvesTrack->setFormationWellPath( wellPath ); stabilityCurvesTrack->setFormationCase( geoMechView->geoMechCase() ); - stabilityCurvesTrack->setShowFormations( true ); + stabilityCurvesTrack->setShowFormations( RiuPlotAnnotationTool::NONE ); stabilityCurvesTrack->setShowFormationLabels( false ); std::vector resultNames = RiaDefines::wellPathStabilityResultNames(); @@ -227,8 +227,13 @@ void RicNewWellBoreStabilityPlotFeature::createStabilityCurvesTrack( RimWellBore { const QString& resultName = resultNames[i]; RigFemResultAddress resAddr( RIG_WELLPATH_DERIVED, resultName.toStdString(), "" ); - RimWellLogExtractionCurve* curve = - RicWellLogTools::addExtractionCurve( stabilityCurvesTrack, geoMechView, wellPath, nullptr, 0, false, false ); + RimWellLogExtractionCurve* curve = RicWellLogTools::addExtractionCurve( stabilityCurvesTrack, + geoMechView, + wellPath, + nullptr, + -1, + false, + false ); curve->setGeoMechResultAddress( resAddr ); curve->setCurrentTimeStep( geoMechView->currentTimeStep() ); curve->setCustomName( resultName ); @@ -263,7 +268,7 @@ void RicNewWellBoreStabilityPlotFeature::createAnglesTrack( RimWellBoreStability const QString& resultName = resultNames[i]; RigFemResultAddress resAddr( RIG_WELLPATH_DERIVED, resultName.toStdString(), "" ); RimWellLogExtractionCurve* curve = - RicWellLogTools::addExtractionCurve( wellPathAnglesTrack, geoMechView, wellPath, nullptr, 0, false, false ); + RicWellLogTools::addExtractionCurve( wellPathAnglesTrack, geoMechView, wellPath, nullptr, -1, false, false ); curve->setGeoMechResultAddress( resAddr ); curve->setCurrentTimeStep( geoMechView->currentTimeStep() ); curve->setCustomName( resultName ); @@ -275,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; @@ -293,6 +298,6 @@ void RicNewWellBoreStabilityPlotFeature::createAnglesTrack( RimWellBoreStability wellPathAnglesTrack->setXAxisGridVisibility( RimWellLogPlot::AXIS_GRID_MAJOR_AND_MINOR ); wellPathAnglesTrack->setFormationWellPath( wellPath ); wellPathAnglesTrack->setFormationCase( geoMechView->geoMechCase() ); - wellPathAnglesTrack->setShowFormations( true ); + wellPathAnglesTrack->setShowFormations( RiuPlotAnnotationTool::NONE ); wellPathAnglesTrack->setShowFormationLabels( false ); } diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.cpp index cd14068601..a24f647f0a 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.cpp @@ -70,6 +70,7 @@ void RicNewWellLogCurveExtractionFeature::onActionTriggered( bool isChecked ) { if ( RicWellLogPlotCurveFeatureImpl::parentWellAllocationPlot() ) return; + RimWellLogPlot* wellLogPlot = caf::SelectionManager::instance()->selectedItemOfType(); RimWellLogTrack* wellLogPlotTrack = caf::SelectionManager::instance()->selectedItemOfType(); if ( wellLogPlotTrack ) { @@ -77,10 +78,10 @@ void RicNewWellLogCurveExtractionFeature::onActionTriggered( bool isChecked ) } else { - RimWellPath* wellPath = caf::SelectionManager::instance()->selectedItemOfType(); - int branchIndex = -1; - RimSimWellInView* simWell = RicWellLogTools::selectedSimulationWell( &branchIndex ); - + RimWellPath* wellPath = caf::SelectionManager::instance()->selectedItemOfType(); + int branchIndex = -1; + RimSimWellInView* simWell = RicWellLogTools::selectedSimulationWell( &branchIndex ); + Rim3dView* view = RiaApplication::instance()->activeReservoirView(); bool useBranchDetection = true; RimSimWellInViewCollection* simWellColl = nullptr; if ( simWell ) @@ -91,11 +92,29 @@ void RicNewWellLogCurveExtractionFeature::onActionTriggered( bool isChecked ) if ( wellPath || simWell ) { - RimWellLogTrack* newWellLogPlotTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack(); + RimWellLogTrack* newWellLogPlotTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack( true, + "", + wellLogPlot ); + if ( wellPath ) + { + newWellLogPlotTrack->setFormationWellPath( wellPath ); + newWellLogPlotTrack->setFormationTrajectoryType( RimWellLogTrack::WELL_PATH ); + } + else + { + newWellLogPlotTrack->setFormationSimWellName( simWell->name() ); + newWellLogPlotTrack->setFormationTrajectoryType( RimWellLogTrack::SIMULATION_WELL ); + newWellLogPlotTrack->setFormationBranchIndex( branchIndex ); + newWellLogPlotTrack->setFormationBranchDetection( useBranchDetection ); + } + + if ( view ) + { + newWellLogPlotTrack->setFormationCase( view->ownerCase() ); + } RimWellLogExtractionCurve* plotCurve = RicWellLogTools::addExtractionCurve( newWellLogPlotTrack, - RiaApplication::instance() - ->activeReservoirView(), + view, wellPath, simWell, branchIndex, @@ -103,11 +122,10 @@ void RicNewWellLogCurveExtractionFeature::onActionTriggered( bool isChecked ) plotCurve->loadDataAndUpdate( true ); - RimWellLogPlot* plot = nullptr; - newWellLogPlotTrack->firstAncestorOrThisOfType( plot ); - if ( plot && plotCurve->curveData() ) + newWellLogPlotTrack->firstAncestorOrThisOfType( wellLogPlot ); + if ( wellLogPlot && plotCurve->curveData() ) { - plot->setDepthUnit( plotCurve->curveData()->depthUnit() ); + wellLogPlot->setDepthUnit( plotCurve->curveData()->depthUnit() ); } plotCurve->updateConnectedEditors(); diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotFeature.cpp index 473b326446..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,12 @@ 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/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.cpp index da39dba564..6ff2a2eb67 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.cpp @@ -19,12 +19,18 @@ #include "RicNewWellLogPlotFeatureImpl.h" +#include "RiaApplication.h" + +#include "RimCase.h" +#include "RimEclipseCase.h" #include "RimMainPlotCollection.h" #include "RimProject.h" #include "RimWellBoreStabilityPlot.h" +#include "RimWellLogCurveCommonDataSource.h" #include "RimWellLogPlot.h" #include "RimWellLogPlotCollection.h" #include "RimWellLogTrack.h" +#include "RimWellPath.h" #include "RiaGuiApplication.h" @@ -114,6 +120,48 @@ RimWellLogTrack* RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack( bool plot = createWellLogPlot(); } + RimCase* caseToApply = nullptr; + RimWellPath* wellPathToApply = nullptr; + QString simWellToApply; + + RimWellLogCurveCommonDataSource* commonDataSource = plot->commonDataSource(); + caseToApply = commonDataSource->caseToApply(); + wellPathToApply = commonDataSource->wellPathToApply(); + simWellToApply = commonDataSource->simWellNameToApply(); + caf::Tristate branchDetectionToApply = commonDataSource->branchDetectionToApply(); + int branchIndexToApply = commonDataSource->branchIndexToApply(); + + if ( !caseToApply ) + { + std::vector allCases; + RiaApplication::instance()->project()->allCases( allCases ); + if ( !allCases.empty() ) + { + caseToApply = allCases.front(); + } + } + + if ( !wellPathToApply && caseToApply ) + { + auto allWellPaths = RiaApplication::instance()->project()->allWellPaths(); + if ( !allWellPaths.empty() ) + { + wellPathToApply = allWellPaths.front(); + } + } + if ( simWellToApply.isEmpty() && caseToApply ) + { + RimEclipseCase* eclipseCase = dynamic_cast( caseToApply ); + if ( eclipseCase ) + { + auto allSimWells = eclipseCase->sortedSimWellNames(); + if ( !allSimWells.empty() ) + { + simWellToApply = *allSimWells.begin(); + } + } + } + RimWellLogTrack* plotTrack = new RimWellLogTrack(); plot->addTrack( plotTrack ); if ( !trackDescription.isEmpty() ) @@ -125,6 +173,40 @@ RimWellLogTrack* RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack( bool plotTrack->setDescription( QString( "Track %1" ).arg( plot->trackCount() ) ); } + if ( caseToApply ) + { + plotTrack->setFormationCase( caseToApply ); + } + + if ( wellPathToApply ) + { + plotTrack->setFormationWellPath( wellPathToApply ); + } + + if ( !simWellToApply.isEmpty() ) + { + plotTrack->setFormationSimWellName( simWellToApply ); + } + + if ( wellPathToApply ) + { + plotTrack->setFormationTrajectoryType( RimWellLogTrack::WELL_PATH ); + } + else if ( !simWellToApply.isEmpty() ) + { + plotTrack->setFormationTrajectoryType( RimWellLogTrack::SIMULATION_WELL ); + } + + if ( !branchDetectionToApply.isPartiallyTrue() ) + { + plotTrack->setFormationBranchDetection( branchDetectionToApply.isTrue() ); + } + + if ( branchIndexToApply >= 0 ) + { + plotTrack->setFormationBranchIndex( branchIndexToApply ); + } + if ( updateAfter ) { updateAfterCreation( plot ); diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp index e7a6689853..2f4a0f4d4a 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp @@ -1097,7 +1097,7 @@ void RimWellPltPlot::onLoadDataAndUpdate() { if ( trackCount() > 0 ) { - trackByIndex( 0 )->setShowFormations( true ); + trackByIndex( 0 )->setShowFormations( RiuPlotAnnotationTool::COLOR_SHADING_AND_LINES ); } m_isOnLoad = false; } diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp index 72b2b73d44..ae0d6362a2 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp @@ -936,7 +936,7 @@ void RimWellRftPlot::onLoadDataAndUpdate() { if ( trackCount() > 0 ) { - trackByIndex( 0 )->setShowFormations( true ); + trackByIndex( 0 )->setShowFormations( RiuPlotAnnotationTool::COLOR_SHADING_AND_LINES ); } m_isOnLoad = false; 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..5473dd7900 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogCurve.cpp @@ -19,6 +19,7 @@ #include "RimWellLogCurve.h" +#include "RiaCurveDataTools.h" #include "RigWellLogCurveData.h" #include "RimWellLogPlot.h" @@ -33,6 +34,8 @@ #include "qwt_symbol.h" +#include + // NB! Special macro for pure virtual class CAF_PDM_XML_ABSTRACT_SOURCE_INIT( RimWellLogCurve, "WellLogPlotCurve" ); @@ -55,9 +58,31 @@ RimWellLogCurve::~RimWellLogCurve() {} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimWellLogCurve::valueRange( double* minimumValue, double* maximumValue ) const +bool RimWellLogCurve::xValueRangeInData( double* minimumValue, double* maximumValue ) const { - return xValueRange( minimumValue, maximumValue ); + CAF_ASSERT( minimumValue && maximumValue ); + + if ( !( minimumValue && maximumValue ) ) + { + return false; + } + if ( m_curveData->xValues().empty() ) + { + return false; + } + + *minimumValue = std::numeric_limits::infinity(); + *maximumValue = -std::numeric_limits::infinity(); + + for ( double xValue : m_curveData->xValues() ) + { + if ( RiaCurveDataTools::isValidValue( xValue, false ) ) + { + *minimumValue = std::min( *minimumValue, xValue ); + *maximumValue = std::max( *maximumValue, xValue ); + } + } + 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/RimWellLogCurveCommonDataSource.cpp b/ApplicationCode/ProjectDataModel/RimWellLogCurveCommonDataSource.cpp index 53b6587d3e..fa08b7a8f4 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogCurveCommonDataSource.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogCurveCommonDataSource.cpp @@ -52,7 +52,7 @@ RimWellLogCurveCommonDataSource::RimWellLogCurveCommonDataSource() CAF_PDM_InitFieldNoDefault( &m_wellPath, "CurveWellPath", "Well Name", "", "", "" ); - CAF_PDM_InitField( &m_simWellName, "SimulationWellName", QString( "None" ), "Well Name", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_simWellName, "SimulationWellName", "Well Name", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_branchDetection, "BranchDetection", "Branch Detection", @@ -117,6 +117,14 @@ void RimWellLogCurveCommonDataSource::setWellPathToApply( RimWellPath* val ) m_wellPath = val; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimWellLogCurveCommonDataSource::branchIndexToApply() const +{ + return m_branchIndex; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -125,6 +133,14 @@ void RimWellLogCurveCommonDataSource::setBranchIndexToApply( int val ) m_branchIndex = val; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::Tristate RimWellLogCurveCommonDataSource::branchDetectionToApply() const +{ + return m_branchDetection(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -177,6 +193,13 @@ void RimWellLogCurveCommonDataSource::resetDefaultOptions() setBranchDetectionToApply( caf::Tristate::State::PartiallyTrue ); setSimWellNameToApply( QString( "" ) ); setTimeStepToApply( -1 ); + + m_uniqueCases.clear(); + m_uniqueTrajectoryTypes.clear(); + m_uniqueWellPaths.clear(); + m_uniqueWellNames.clear(); + m_uniqueTimeSteps.clear(); + m_uniqueBranchIndices.clear(); } //-------------------------------------------------------------------------------------------------- @@ -189,13 +212,6 @@ void RimWellLogCurveCommonDataSource::updateDefaultOptions( const std::vector uniqueCases; - std::set uniqueTrajectoryTypes; - std::set uniqueWellPaths; - std::set uniqueWellNames; - std::set uniqueTimeSteps; - std::set uniqueBranchDetection; - std::set uniqueBranchIndex; for ( RimWellLogCurve* curve : curves ) { if ( !curve->isCurveVisible() ) @@ -206,65 +222,93 @@ void RimWellLogCurveCommonDataSource::updateDefaultOptions( const std::vector( curve ); if ( extractionCurve ) { - uniqueCases.insert( extractionCurve->rimCase() ); - uniqueTrajectoryTypes.insert( static_cast( extractionCurve->trajectoryType() ) ); - uniqueWellPaths.insert( extractionCurve->wellPath() ); - uniqueWellNames.insert( extractionCurve->wellName() ); - uniqueTimeSteps.insert( extractionCurve->currentTimeStep() ); - uniqueBranchDetection.insert( extractionCurve->branchDetection() ); - uniqueBranchIndex.insert( extractionCurve->branchIndex() ); + if ( extractionCurve->rimCase() ) + { + m_uniqueCases.insert( extractionCurve->rimCase() ); + } + m_uniqueTrajectoryTypes.insert( static_cast( extractionCurve->trajectoryType() ) ); + if ( extractionCurve->trajectoryType() == RimWellLogTrack::WELL_PATH ) + { + if ( extractionCurve->wellPath() ) + { + m_uniqueWellPaths.insert( extractionCurve->wellPath() ); + } + } + else if ( extractionCurve->trajectoryType() == RimWellLogTrack::SIMULATION_WELL ) + { + if ( !extractionCurve->wellName().isEmpty() ) + { + m_uniqueWellNames.insert( extractionCurve->wellName() ); + } + } + + m_uniqueTimeSteps.insert( extractionCurve->currentTimeStep() ); + m_uniqueBranchDetection.insert( extractionCurve->branchDetection() ); + m_uniqueBranchIndices.insert( extractionCurve->branchIndex() ); } else if ( fileCurve ) { - uniqueWellPaths.insert( fileCurve->wellPath() ); - uniqueWellNames.insert( fileCurve->wellName() ); + m_uniqueWellPaths.insert( fileCurve->wellPath() ); + m_uniqueWellNames.insert( fileCurve->wellName() ); } } for ( RimWellLogTrack* track : tracks ) { if ( track->showWellPathAttributes() ) { - uniqueTrajectoryTypes.insert( static_cast( RimWellLogExtractionCurve::WELL_PATH ) ); - uniqueWellPaths.insert( track->wellPathAttributeSource() ); + m_uniqueTrajectoryTypes.insert( static_cast( RimWellLogExtractionCurve::WELL_PATH ) ); + m_uniqueWellPaths.insert( track->wellPathAttributeSource() ); } if ( track->showFormations() ) { - uniqueCases.insert( track->formationNamesCase() ); - uniqueWellPaths.insert( track->formationWellPath() ); + m_uniqueTrajectoryTypes.insert( track->formationTrajectoryType() ); + if ( track->formationTrajectoryType() == RimWellLogTrack::WELL_PATH ) + { + m_uniqueWellPaths.insert( track->formationWellPath() ); + } + else if ( track->formationTrajectoryType() == RimWellLogTrack::SIMULATION_WELL ) + { + m_uniqueWellNames.insert( track->formationSimWellName() ); + } + m_uniqueBranchDetection.insert( track->formationBranchDetection() ); + m_uniqueBranchIndices.insert( track->formationBranchIndex() ); + + m_uniqueCases.insert( track->formationNamesCase() ); + m_uniqueWellPaths.insert( track->formationWellPath() ); } } - if ( uniqueCases.size() == 1u ) + if ( m_uniqueCases.size() == 1u ) { - setCaseToApply( *uniqueCases.begin() ); + setCaseToApply( *m_uniqueCases.begin() ); } - if ( uniqueTrajectoryTypes.size() == 1u ) + if ( m_uniqueTrajectoryTypes.size() == 1u ) { - m_trajectoryType = *uniqueTrajectoryTypes.begin(); + m_trajectoryType = *m_uniqueTrajectoryTypes.begin(); - if ( uniqueWellPaths.size() == 1u ) + if ( m_uniqueWellPaths.size() == 1u ) { - setWellPathToApply( *uniqueWellPaths.begin() ); + setWellPathToApply( *m_uniqueWellPaths.begin() ); } - if ( uniqueBranchIndex.size() == 1u ) + if ( m_uniqueBranchIndices.size() == 1u ) { - setBranchIndexToApply( *uniqueBranchIndex.begin() ); + setBranchIndexToApply( *m_uniqueBranchIndices.begin() ); } - if ( uniqueBranchDetection.size() == 1u ) + if ( m_uniqueBranchDetection.size() == 1u ) { - setBranchDetectionToApply( *uniqueBranchDetection.begin() == true ? caf::Tristate::State::True - : caf::Tristate::State::False ); + setBranchDetectionToApply( *m_uniqueBranchDetection.begin() == true ? caf::Tristate::State::True + : caf::Tristate::State::False ); } - if ( uniqueWellNames.size() == 1u ) + if ( m_uniqueWellNames.size() == 1u ) { - setSimWellNameToApply( *uniqueWellNames.begin() ); + setSimWellNameToApply( *m_uniqueWellNames.begin() ); } } - if ( uniqueTimeSteps.size() == 1u ) + if ( m_uniqueTimeSteps.size() == 1u ) { - setTimeStepToApply( *uniqueTimeSteps.begin() ); + setTimeStepToApply( *m_uniqueTimeSteps.begin() ); } } @@ -379,29 +423,48 @@ void RimWellLogCurveCommonDataSource::updateCurvesAndTracks( std::vectorshowFormations() ) - { - track->setFormationCase( caseToApply() ); - updatedSomething = true; - } - } - if ( wellPathToApply() != nullptr ) + if ( track->showWellPathAttributes() ) { - if ( track->showWellPathAttributes() ) + if ( wellPathToApply() ) { track->setWellPathAttributesSource( wellPathToApply() ); updatedSomething = true; } - if ( track->showFormations() ) + } + + if ( track->showFormations() ) + { + if ( caseToApply() != nullptr ) + { + track->setFormationCase( caseToApply() ); + updatedSomething = true; + } + + if ( wellPathToApply() != nullptr ) { track->setFormationWellPath( wellPathToApply() ); updatedSomething = true; } - } + if ( !simWellNameToApply().isEmpty() ) + { + track->setFormationSimWellName( simWellNameToApply() ); + updatedSomething = true; + } + + if ( !branchDetectionToApply().isPartiallyTrue() ) + { + track->setFormationSimWellName( simWellNameToApply() ); + updatedSomething = true; + } + + if ( branchIndexToApply() >= 0 ) + { + track->setFormationBranchIndex( branchIndexToApply() ); + updatedSomething = true; + } + } if ( updatedSomething ) { RimWellLogPlot* parentPlot = nullptr; @@ -560,14 +623,28 @@ QList if ( caseToApply() == nullptr ) { - options.push_front( caf::PdmOptionItemInfo( "Mixed Cases", nullptr ) ); + if ( !m_uniqueCases.empty() ) + { + options.push_front( caf::PdmOptionItemInfo( "Mixed Cases", nullptr ) ); + } + else + { + options.push_front( caf::PdmOptionItemInfo( "None", nullptr ) ); + } } } else if ( fieldNeedingOptions == &m_trajectoryType ) { if ( m_trajectoryType() == -1 ) { - options.push_back( caf::PdmOptionItemInfo( "Mixed Trajectory Types", -1 ) ); + if ( !m_uniqueTrajectoryTypes.empty() ) + { + options.push_back( caf::PdmOptionItemInfo( "Mixed Trajectory Types", -1 ) ); + } + else + { + options.push_back( caf::PdmOptionItemInfo( "No Trajectory Types", -1 ) ); + } } std::vector trajectoryTypes = {RimWellLogExtractionCurve::WELL_PATH, RimWellLogExtractionCurve::SIMULATION_WELL}; @@ -583,7 +660,14 @@ QList RimTools::wellPathOptionItems( &options ); if ( wellPathToApply() == nullptr ) { - options.push_front( caf::PdmOptionItemInfo( "Mixed Well Paths", nullptr ) ); + if ( !m_uniqueWellPaths.empty() ) + { + options.push_front( caf::PdmOptionItemInfo( "Mixed Well Paths", nullptr ) ); + } + else + { + options.push_front( caf::PdmOptionItemInfo( "None", nullptr ) ); + } } } else if ( fieldNeedingOptions == &m_timeStep ) @@ -602,7 +686,14 @@ QList if ( timeStepToApply() == -1 ) { - options.push_front( caf::PdmOptionItemInfo( "Mixed Time Steps", -1 ) ); + if ( !m_uniqueTimeSteps.empty() ) + { + options.push_front( caf::PdmOptionItemInfo( "Mixed Time Steps", -1 ) ); + } + else + { + options.push_front( caf::PdmOptionItemInfo( "No Time Steps", -1 ) ); + } } } else if ( fieldNeedingOptions == &m_simWellName ) @@ -618,14 +709,16 @@ QList options.push_back( caf::PdmOptionItemInfo( wname, wname, false, simWellIcon ) ); } - if ( options.size() == 0 ) + if ( m_simWellName().isEmpty() ) { - options.push_front( caf::PdmOptionItemInfo( "None", "None" ) ); - } - - if ( m_simWellName == QString( "" ) ) - { - options.push_front( caf::PdmOptionItemInfo( "Mixed Well Names", "" ) ); + if ( !m_uniqueWellNames.empty() ) + { + options.push_front( caf::PdmOptionItemInfo( "Mixed Well Names", "" ) ); + } + else + { + options.push_front( caf::PdmOptionItemInfo( "None", "None" ) ); + } } } } @@ -641,7 +734,14 @@ QList if ( m_branchIndex() == -1 ) { - options.push_front( caf::PdmOptionItemInfo( "Mixed Branches", -1 ) ); + if ( !m_uniqueBranchIndices.empty() ) + { + options.push_front( caf::PdmOptionItemInfo( "Mixed Branches", -1 ) ); + } + else + { + options.push_front( caf::PdmOptionItemInfo( "No Branches", -1 ) ); + } } } } diff --git a/ApplicationCode/ProjectDataModel/RimWellLogCurveCommonDataSource.h b/ApplicationCode/ProjectDataModel/RimWellLogCurveCommonDataSource.h index be6043ccca..04677029f5 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogCurveCommonDataSource.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogCurveCommonDataSource.h @@ -42,18 +42,21 @@ class RimWellLogCurveCommonDataSource : public caf::PdmObject public: RimWellLogCurveCommonDataSource(); - RimCase* caseToApply() const; - void setCaseToApply( RimCase* val ); - int trajectoryTypeToApply() const; - void setTrajectoryTypeToApply( int val ); - RimWellPath* wellPathToApply() const; - void setWellPathToApply( RimWellPath* val ); - void setBranchIndexToApply( int val ); - void setBranchDetectionToApply( caf::Tristate::State val ); - QString simWellNameToApply() const; - void setSimWellNameToApply( const QString& val ); - int timeStepToApply() const; - void setTimeStepToApply( int val ); + RimCase* caseToApply() const; + void setCaseToApply( RimCase* val ); + int trajectoryTypeToApply() const; + void setTrajectoryTypeToApply( int val ); + RimWellPath* wellPathToApply() const; + void setWellPathToApply( RimWellPath* val ); + int branchIndexToApply() const; + void setBranchIndexToApply( int val ); + caf::Tristate branchDetectionToApply() const; + void setBranchDetectionToApply( caf::Tristate::State val ); + + QString simWellNameToApply() const; + void setSimWellNameToApply( const QString& val ); + int timeStepToApply() const; + void setTimeStepToApply( int val ); void resetDefaultOptions(); void updateDefaultOptions( const std::vector& curves, const std::vector& tracks ); @@ -90,4 +93,12 @@ private: caf::PdmField m_branchIndex; caf::PdmField m_branchDetection; caf::PdmField m_timeStep; + + std::set m_uniqueCases; + std::set m_uniqueTrajectoryTypes; + std::set m_uniqueWellPaths; + std::set m_uniqueWellNames; + std::set m_uniqueTimeSteps; + std::set m_uniqueBranchDetection; + std::set m_uniqueBranchIndices; }; diff --git a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp index 8d4441677d..34b3749d41 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp @@ -96,7 +96,7 @@ RimWellLogExtractionCurve::RimWellLogExtractionCurve() CAF_PDM_InitFieldNoDefault( &m_wellPath, "CurveWellPath", "Well Name", "", "", "" ); m_wellPath.uiCapability()->setUiTreeChildrenHidden( true ); - CAF_PDM_InitField( &m_simWellName, "SimulationWellName", QString( "None" ), "Well Name", "", "", "" ); + CAF_PDM_InitField( &m_simWellName, "SimulationWellName", QString( "" ), "Well Name", "", "", "" ); CAF_PDM_InitField( &m_branchDetection, "BranchDetection", true, @@ -195,7 +195,10 @@ RimCase* RimWellLogExtractionCurve::rimCase() const //-------------------------------------------------------------------------------------------------- void RimWellLogExtractionCurve::setPropertiesFromView( Rim3dView* view ) { - m_case = view ? view->ownerCase() : nullptr; + if ( view ) + { + m_case = view->ownerCase(); + } RimGeoMechCase* geomCase = dynamic_cast( m_case.value() ); RimEclipseCase* eclipseCase = dynamic_cast( m_case.value() ); @@ -209,6 +212,10 @@ void RimWellLogExtractionCurve::setPropertiesFromView( Rim3dView* view ) m_timeStep = eclipseView->currentTimeStep(); } + else if ( eclipseCase ) + { + m_eclipseResultDefinition->setResultVariable( "SOIL" ); + } RimGeoMechView* geoMechView = dynamic_cast( view ); if ( geoMechView ) @@ -216,6 +223,10 @@ void RimWellLogExtractionCurve::setPropertiesFromView( Rim3dView* view ) m_geomResultDefinition->setResultAddress( geoMechView->cellResultResultDefinition()->resultAddress() ); m_timeStep = geoMechView->currentTimeStep(); } + else if ( geomCase ) + { + m_geomResultDefinition->setResultAddress( RigFemResultAddress( RIG_ELEMENT, "POR", "" ) ); + } clearGeneratedSimWellPaths(); } @@ -276,7 +287,7 @@ void RimWellLogExtractionCurve::fieldChangedByUi( const caf::PdmFieldHandle* cha clampTimestep(); auto wellNameSet = sortedSimWellNames(); - if ( !wellNameSet.count( m_simWellName() ) ) m_simWellName = "None"; + if ( !wellNameSet.count( m_simWellName() ) ) m_simWellName = ""; clearGeneratedSimWellPaths(); @@ -321,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; @@ -464,6 +362,8 @@ void RimWellLogExtractionCurve::onLoadDataAndUpdate( bool updateParentPlot ) m_qwtPlotCurve->setLineSegmentStartStopIndices( m_curveData->polylineStartStopIndices() ); + this->RimPlotCurve::updateCurvePresentation( updateParentPlot ); + if ( isUsingPseudoLength ) { RimWellLogTrack* wellLogTrack; @@ -491,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. //-------------------------------------------------------------------------------------------------- @@ -584,14 +603,10 @@ QList if ( fieldNeedingOptions == &m_wellPath ) { RimTools::wellPathOptionItems( &options ); - - options.push_front( caf::PdmOptionItemInfo( "None", nullptr ) ); } else if ( fieldNeedingOptions == &m_case ) { RimTools::caseOptionItems( &options ); - - options.push_front( caf::PdmOptionItemInfo( "None", nullptr ) ); } else if ( fieldNeedingOptions == &m_timeStep ) { @@ -616,11 +631,6 @@ QList { options.push_back( caf::PdmOptionItemInfo( wname, wname, false, simWellIcon ) ); } - - if ( options.size() == 0 ) - { - options.push_front( caf::PdmOptionItemInfo( "None", "None" ) ); - } } else if ( fieldNeedingOptions == &m_branchIndex ) { 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 300e04c863..2d1082b686 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp @@ -289,11 +289,6 @@ void RimWellLogTrack::simWellOptionItems( QList* options { options->push_back( caf::PdmOptionItemInfo( wname, wname, false, simWellIcon ) ); } - - if ( options->size() == 0 ) - { - options->push_front( caf::PdmOptionItemInfo( "None", "None" ) ); - } } //-------------------------------------------------------------------------------------------------- @@ -606,18 +601,14 @@ QList RimWellLogTrack::calculateValueOptions( const caf: if ( fieldNeedingOptions == &m_formationWellPathForSourceCase ) { RimTools::wellPathOptionItems( &options ); - options.push_front( caf::PdmOptionItemInfo( "None", nullptr ) ); } else if ( fieldNeedingOptions == &m_formationWellPathForSourceWellPath ) { RimTools::wellPathWithFormationsOptionItems( &options ); - options.push_front( caf::PdmOptionItemInfo( "None", nullptr ) ); } else if ( fieldNeedingOptions == &m_formationCase ) { RimTools::caseOptionItems( &options ); - - options.push_front( caf::PdmOptionItemInfo( "None", nullptr ) ); } else if ( fieldNeedingOptions == &m_formationSimWellName ) { @@ -769,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 ) { @@ -986,6 +977,30 @@ void RimWellLogTrack::setFormationSimWellName( const QString& simWellName ) m_formationSimWellName = simWellName; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimWellLogTrack::formationSimWellName() const +{ + return m_formationSimWellName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogTrack::setFormationBranchDetection( bool branchDetection ) +{ + m_formationBranchDetection = branchDetection; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimWellLogTrack::formationBranchDetection() const +{ + return m_formationBranchDetection(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -994,6 +1009,14 @@ void RimWellLogTrack::setFormationBranchIndex( int branchIndex ) m_formationBranchIndex = branchIndex; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimWellLogTrack::formationBranchIndex() const +{ + return m_formationBranchIndex; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1002,6 +1025,14 @@ void RimWellLogTrack::setFormationCase( RimCase* rimCase ) m_formationCase = rimCase; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCase* RimWellLogTrack::formationNamesCase() const +{ + return m_formationCase(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1013,9 +1044,9 @@ void RimWellLogTrack::setFormationTrajectoryType( TrajectoryType trajectoryType //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimCase* RimWellLogTrack::formationNamesCase() const +RimWellLogTrack::TrajectoryType RimWellLogTrack::formationTrajectoryType() const { - return m_formationCase(); + return m_formationTrajectoryType(); } //-------------------------------------------------------------------------------------------------- @@ -1144,7 +1175,7 @@ void RimWellLogTrack::calculateXZoomRange() if ( curve->isCurveVisible() ) { visibleCurves++; - if ( curve->xValueRange( &minCurveValue, &maxCurveValue ) ) + if ( curve->xValueRangeInData( &minCurveValue, &maxCurveValue ) ) { if ( minCurveValue < minValue ) { @@ -1248,9 +1279,9 @@ void RimWellLogTrack::setXAxisGridVisibility( RimWellLogPlot::AxisGridVisibility //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogTrack::setShowFormations( bool on ) +void RimWellLogTrack::setShowFormations( RiuPlotAnnotationTool::FormationDisplay formationDisplay ) { - m_showFormations_OBSOLETE = on; + m_formationDisplay = formationDisplay; } //-------------------------------------------------------------------------------------------------- @@ -1258,7 +1289,7 @@ void RimWellLogTrack::setShowFormations( bool on ) //-------------------------------------------------------------------------------------------------- bool RimWellLogTrack::showFormations() const { - return m_showFormations_OBSOLETE; + return m_formationDisplay() != RiuPlotAnnotationTool::NONE; } //-------------------------------------------------------------------------------------------------- @@ -1324,23 +1355,23 @@ RimWellLogCurve* RimWellLogTrack::curveDefinitionFromCurve( const QwtPlotCurve* void RimWellLogTrack::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { uiOrdering.add( &m_userName ); - caf::PdmUiGroup* formationGroup = uiOrdering.addNewGroup( "Zonation/Formation Names" ); + caf::PdmUiGroup* annotationGroup = uiOrdering.addNewGroup( "Regions/Annotations" ); - formationGroup->add( &m_formationDisplay ); + annotationGroup->add( &m_formationDisplay ); if ( m_formationDisplay() & RiuPlotAnnotationTool::COLOR_SHADING || m_formationDisplay() & RiuPlotAnnotationTool::COLORED_LINES ) { - formationGroup->add( &m_colorShadingPalette ); + annotationGroup->add( &m_colorShadingPalette ); if ( m_formationDisplay() & RiuPlotAnnotationTool::COLOR_SHADING ) { - formationGroup->add( &m_colorShadingTransparency ); + annotationGroup->add( &m_colorShadingTransparency ); } } - formationGroup->add( &m_showFormationLabels ); + annotationGroup->add( &m_showFormationLabels ); if ( !m_formationsForCaseWithSimWellOnly ) { - formationGroup->add( &m_formationSource ); + annotationGroup->add( &m_formationSource ); } else { @@ -1349,23 +1380,23 @@ void RimWellLogTrack::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering if ( m_formationSource() == CASE ) { - formationGroup->add( &m_formationCase ); + annotationGroup->add( &m_formationCase ); if ( !m_formationsForCaseWithSimWellOnly ) { - formationGroup->add( &m_formationTrajectoryType ); + annotationGroup->add( &m_formationTrajectoryType ); if ( m_formationTrajectoryType() == WELL_PATH ) { - formationGroup->add( &m_formationWellPathForSourceCase ); + annotationGroup->add( &m_formationWellPathForSourceCase ); } } if ( m_formationsForCaseWithSimWellOnly || m_formationTrajectoryType() == SIMULATION_WELL ) { - formationGroup->add( &m_formationSimWellName ); + annotationGroup->add( &m_formationSimWellName ); - RiaSimWellBranchTools::appendSimWellBranchFieldsIfRequiredFromSimWellName( formationGroup, + RiaSimWellBranchTools::appendSimWellBranchFieldsIfRequiredFromSimWellName( annotationGroup, m_formationSimWellName, m_formationBranchDetection, m_formationBranchIndex ); @@ -1373,11 +1404,11 @@ void RimWellLogTrack::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering } else if ( m_formationSource() == WELL_PICK_FILTER ) { - formationGroup->add( &m_formationWellPathForSourceWellPath ); + annotationGroup->add( &m_formationWellPathForSourceWellPath ); if ( m_formationWellPathForSourceWellPath() ) { - formationGroup->add( &m_formationLevel ); - formationGroup->add( &m_showformationFluids ); + annotationGroup->add( &m_formationLevel ); + annotationGroup->add( &m_showformationFluids ); } } @@ -1653,7 +1684,7 @@ RigEclipseWellLogExtractor* RimWellLogTrack::createSimWellExtractor( RimWellLogP if ( wellPaths.size() == 0 ) return nullptr; - CVF_ASSERT( branchIndex < static_cast( wellPaths.size() ) ); + CVF_ASSERT( branchIndex >= 0 && branchIndex < static_cast( wellPaths.size() ) ); return ( wellLogCollection->findOrCreateSimWellExtractor( simWellName, QString( "Find or create sim well extractor" ), diff --git a/ApplicationCode/ProjectDataModel/RimWellLogTrack.h b/ApplicationCode/ProjectDataModel/RimWellLogTrack.h index 17b822ac57..76b2d1fbc5 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogTrack.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogTrack.h @@ -108,13 +108,18 @@ public: int widthScaleFactor() const; void setWidthScaleFactor( WidthScaleFactor scaleFactor ); - void setFormationWellPath( RimWellPath* wellPath ); - RimWellPath* formationWellPath() const; - void setFormationSimWellName( const QString& simWellName ); - void setFormationBranchIndex( int branchIndex ); - void setFormationCase( RimCase* rimCase ); - void setFormationTrajectoryType( TrajectoryType trajectoryType ); - RimCase* formationNamesCase() const; + void setFormationWellPath( RimWellPath* wellPath ); + RimWellPath* formationWellPath() const; + void setFormationSimWellName( const QString& simWellName ); + QString formationSimWellName() const; + void setFormationBranchDetection( bool branchDetection ); + bool formationBranchDetection() const; + void setFormationBranchIndex( int branchIndex ); + int formationBranchIndex() const; + void setFormationCase( RimCase* rimCase ); + RimCase* formationNamesCase() const; + void setFormationTrajectoryType( TrajectoryType trajectoryType ); + TrajectoryType formationTrajectoryType() const; void recreateViewer(); void detachAllCurves(); @@ -140,7 +145,7 @@ public: void setVisibleXRange( double minValue, double maxValue ); void setTickIntervals( double majorTickInterval, double minorTickInterval ); void setXAxisGridVisibility( RimWellLogPlot::AxisGridVisibility gridLines ); - void setShowFormations( bool on ); + void setShowFormations( RiuPlotAnnotationTool::FormationDisplay formationDisplay ); bool showFormations() const; void setShowFormationLabels( bool on );