This commit is contained in:
Jørgen Herje 2023-05-11 08:51:50 +02:00
parent f4a904b227
commit 05a822f33a
3 changed files with 80 additions and 45 deletions

View File

@ -23,6 +23,7 @@
#include "RicWellLogTools.h" #include "RicWellLogTools.h"
#include "WellLogCommands/RicNewWellLogPlotFeatureImpl.h" #include "WellLogCommands/RicNewWellLogPlotFeatureImpl.h"
#include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h"
#include "RimGeoMechCase.h" #include "RimGeoMechCase.h"
#include "RimGeoMechView.h" #include "RimGeoMechView.h"
@ -151,7 +152,7 @@ void RimGeoMechFaultReactivationResult::defineEditorAttribute( const caf::PdmFie
caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute ); caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute );
if ( attrib ) if ( attrib )
{ {
attrib->m_buttonText = "Create Fault Reactivation Curves"; attrib->m_buttonText = "Create";
} }
} }
} }
@ -262,15 +263,19 @@ void RimGeoMechFaultReactivationResult::createWellLogCurves()
RicWellLogTools::addWellLogExtractionCurve( faultReactivationTrack, geomCase, view, m_faceBWellPath(), nullptr, -1, true ); RicWellLogTools::addWellLogExtractionCurve( faultReactivationTrack, geomCase, view, m_faceBWellPath(), nullptr, -1, true );
faceAWellLogExtractionCurve->setGeoMechResultAddress( wellLogExtractionResult ); faceAWellLogExtractionCurve->setGeoMechResultAddress( wellLogExtractionResult );
faceBWellLogExtractionCurve->setGeoMechResultAddress( wellLogExtractionResult ); faceBWellLogExtractionCurve->setGeoMechResultAddress( wellLogExtractionResult );
faceAWellLogExtractionCurve->updateAllRequiredEditors(); faceAWellLogExtractionCurve->updateConnectedEditors();
faceBWellLogExtractionCurve->updateAllRequiredEditors(); faceBWellLogExtractionCurve->updateConnectedEditors();
// Create well log diff curve for m_faceAWellPath and m_faceBWellPath // Create well log diff curve for m_faceAWellPath and m_faceBWellPath
// RicWellLogTools::addWellLogDiffCurve( faultReactivationTrack, geomCase, view ); // RicWellLogTools::addWellLogDiffCurve( faultReactivationTrack, geomCase, view );
RimWellLogDiffCurve* faceWellLogDiffCurve = new RimWellLogDiffCurve(); RimWellLogDiffCurve* faceWellLogDiffCurve = new RimWellLogDiffCurve();
faceWellLogDiffCurve->setWellLogCurves( faceAWellLogExtractionCurve, faceBWellLogExtractionCurve ); faceWellLogDiffCurve->setWellLogCurves( faceAWellLogExtractionCurve, faceBWellLogExtractionCurve );
faceWellLogDiffCurve->setParentPlotNoReplot( faultReactivationTrack->plotWidget() ); const cvf::Color3f curveColor = RicWellLogPlotCurveFeatureImpl::curveColorFromTable( faultReactivationTrack->curveCount() );
faceWellLogDiffCurve->loadDataAndUpdate( false ); faceWellLogDiffCurve->setColor( curveColor );
faultReactivationTrack->addCurve( faceWellLogDiffCurve ); faultReactivationTrack->addCurve( faceWellLogDiffCurve );
faultReactivationTrack->updateAllRequiredEditors();
faceWellLogDiffCurve->loadDataAndUpdate( true );
faceWellLogDiffCurve->updateConnectedEditors();
faultReactivationTrack->updateConnectedEditors();
} }

View File

@ -19,6 +19,7 @@
#include "RimWellLogDiffCurve.h" #include "RimWellLogDiffCurve.h"
#include "RiaDefines.h" #include "RiaDefines.h"
#include "RiaLogging.h"
#include "RigWellLogCurveData.h" #include "RigWellLogCurveData.h"
@ -33,6 +34,8 @@
#include "RiuPlotCurve.h" #include "RiuPlotCurve.h"
#include "cafPdmUiTreeOrdering.h"
CAF_PDM_SOURCE_INIT( RimWellLogDiffCurve, "WellLogDiffCurve" ); CAF_PDM_SOURCE_INIT( RimWellLogDiffCurve, "WellLogDiffCurve" );
#pragma optimize( "", off ) #pragma optimize( "", off )
@ -47,6 +50,7 @@ RimWellLogDiffCurve::RimWellLogDiffCurve()
CAF_PDM_InitFieldNoDefault( &m_wellLogCurveA, "WellLogCurveA", "Well Log Curve A" ); CAF_PDM_InitFieldNoDefault( &m_wellLogCurveA, "WellLogCurveA", "Well Log Curve A" );
CAF_PDM_InitFieldNoDefault( &m_wellLogCurveB, "WellLogCurveB", "Well Log Curve B" ); CAF_PDM_InitFieldNoDefault( &m_wellLogCurveB, "WellLogCurveB", "Well Log Curve B" );
setNamingMethod( RiaDefines::ObjectNamingMethod::AUTO );
setDeletable( true ); setDeletable( true );
} }
@ -65,7 +69,10 @@ void RimWellLogDiffCurve::setWellLogCurves( RimWellLogCurve* wellLogCurveA, RimW
if ( wellLogCurveA ) m_wellLogCurveA = wellLogCurveA; if ( wellLogCurveA ) m_wellLogCurveA = wellLogCurveA;
if ( wellLogCurveB ) m_wellLogCurveB = wellLogCurveB; if ( wellLogCurveB ) m_wellLogCurveB = wellLogCurveB;
m_curveName = QString( "Diff (%1 - %2)" ).arg( m_wellLogCurveA->curveName() ).arg( m_wellLogCurveB->curveName() ); if ( m_namingMethod() == RiaDefines::ObjectNamingMethod::AUTO )
{
setAutomaticName();
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -73,8 +80,8 @@ void RimWellLogDiffCurve::setWellLogCurves( RimWellLogCurve* wellLogCurveA, RimW
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QString RimWellLogDiffCurve::createCurveAutoName() QString RimWellLogDiffCurve::createCurveAutoName()
{ {
CAF_ASSERT( "TO BE IMPLEMETNED!" ); if ( !m_wellLogCurveA() || !m_wellLogCurveB() ) return QString( "Invalid well log curves" );
return QString(); return QString( "Diff (%1 - %2)" ).arg( m_wellLogCurveA->curveName() ).arg( m_wellLogCurveB->curveName() );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -84,47 +91,73 @@ void RimWellLogDiffCurve::onLoadDataAndUpdate( bool updateParentPlot )
{ {
if ( !m_wellLogCurveA() || !m_wellLogCurveB() ) return; if ( !m_wellLogCurveA() || !m_wellLogCurveB() ) return;
if ( m_namingMethod() == RiaDefines::ObjectNamingMethod::AUTO )
{
setAutomaticName();
}
// Use well A as reference for resampled curve data // Use well A as reference for resampled curve data
auto* curveDataA = m_wellLogCurveA()->curveData(); auto* curveDataA = m_wellLogCurveA()->curveData();
auto* curveDataB = m_wellLogCurveB()->curveData(); auto* curveDataB = m_wellLogCurveB()->curveData();
if ( !curveDataA || !curveDataB ) return; if ( !curveDataA || !curveDataB ) return;
if ( curveDataA->depthUnit() != curveDataB->depthUnit() ) if ( curveDataA->depthUnit() != curveDataB->depthUnit() )
{ {
// Return warning! RiaLogging::warning( "Well log curve depth units are not the same" );
}
if ( curveDataA->propertyValueUnit() != curveDataB->propertyValueUnit() )
{
RiaLogging::warning( "Well log curve property value units are not the same" );
} }
const auto depthUnit = curveDataA->depthUnit();
const auto depthType = RiaDefines::DepthTypeEnum::MEASURED_DEPTH; const auto depthType = RiaDefines::DepthTypeEnum::MEASURED_DEPTH;
const auto curveADepths = curveDataA->depths( depthType ); const auto propertyUnit = curveDataA->propertyValueUnit();
// Get curve A depths and property values
const auto curveADepthValues = curveDataA->depths( depthType );
const auto curveDataAPropertyValues = curveDataA->propertyValues(); const auto curveDataAPropertyValues = curveDataA->propertyValues();
// Resample curve B to curve A // Resample curve B to curve A
cvf::ref<RigWellLogCurveData> curveDataBResampled = curveDataB->calculateResampledCurveData( depthType, curveADepths ); cvf::ref<RigWellLogCurveData> curveDataBResampled = curveDataB->calculateResampledCurveData( depthType, curveADepthValues );
auto curveBDepthValuesResampled = curveDataBResampled->depths( depthType ); auto curveBDepthValuesResampled = curveDataBResampled->depths( depthType );
auto curveBPropertyValuesResampled = curveDataBResampled->propertyValues(); auto curveBPropertyValuesResampled = curveDataBResampled->propertyValues();
// curveDataA size and curveBPropertiesResampled size should be the same // Verify equal sizes
if ( curveADepths.size() != curveDataAPropertyValues.size() ) return; if ( curveADepthValues.size() != curveDataAPropertyValues.size() ) return;
if ( curveADepths.size() != curveBDepthValuesResampled.size() ) return; if ( curveADepthValues.size() != curveBDepthValuesResampled.size() ) return;
if ( curveDataAPropertyValues.size() != curveBPropertyValuesResampled.size() ) return; if ( curveADepthValues.size() != curveBPropertyValuesResampled.size() ) return;
std::vector<double> curveDiffDepthValues( curveADepths.size() ); // Calculate diff curve
std::vector<double> curveDiffDepthValues( curveADepthValues.size() );
std::vector<double> curveDiffPropertyValues( curveDataAPropertyValues.size() ); std::vector<double> curveDiffPropertyValues( curveDataAPropertyValues.size() );
for ( size_t i = 0; i < curveDataAPropertyValues.size(); ++i ) for ( size_t i = 0; i < curveDataAPropertyValues.size(); ++i )
{ {
curveDiffPropertyValues[i] = curveDataAPropertyValues[i] - curveBPropertyValuesResampled[i]; curveDiffPropertyValues[i] = curveDataAPropertyValues[i] - curveBPropertyValuesResampled[i];
curveDiffDepthValues[i] = curveADepths[i]; curveDiffDepthValues[i] = curveADepthValues[i];
} }
const bool useLogarithmicScale = false; const bool useLogarithmicScale = false;
const bool isExtractionCurve = false;
// Set curve data
auto depthsMap = std::map<RiaDefines::DepthTypeEnum, std::vector<double>>(); auto depthsMap = std::map<RiaDefines::DepthTypeEnum, std::vector<double>>();
depthsMap[depthType] = curveDiffDepthValues; depthsMap[depthType] = curveDiffDepthValues;
setPropertyValuesAndDepths( curveDiffPropertyValues, depthsMap, 0.0, curveDataA->depthUnit(), false, false, QString( "" ) ); setPropertyValuesAndDepths( curveDiffPropertyValues, depthsMap, 0.0, depthUnit, isExtractionCurve, useLogarithmicScale, propertyUnit );
// TODO: NOT VISUALISING IN PLOT! // Set curve data to plot
std::vector<double> xPlotValues = curveData()->propertyValuesByIntervals();
std::vector<double> yPlotValues = curveData()->depthValuesByIntervals( depthType, depthUnit );
m_plotCurve->setSamplesFromXValuesAndYValues( xPlotValues, yPlotValues, useLogarithmicScale );
updateCurvePresentation( updateParentPlot );
}
// m_plotCurve->setSamplesFromXValuesAndYValues( curveDiffPropertyValues, curveDiffDepthValues, useLogarithmicScale ); //--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogDiffCurve::setAutomaticName()
{
m_curveName = createCurveAutoName();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -158,12 +191,25 @@ QString RimWellLogDiffCurve::wellLogChannelUnits() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellLogDiffCurve::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) void RimWellLogDiffCurve::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{ {
RimPlotCurve::updateFieldUiState();
caf::PdmUiGroup* group = uiOrdering.addNewGroup( "Data Source" ); caf::PdmUiGroup* group = uiOrdering.addNewGroup( "Data Source" );
group->add( &m_wellLogCurveA ); group->add( &m_wellLogCurveA );
group->add( &m_wellLogCurveB ); group->add( &m_wellLogCurveB );
RimStackablePlotCurve::defaultUiOrdering( uiOrdering );
uiOrdering.skipRemainingFields( true ); uiOrdering.skipRemainingFields( true );
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogDiffCurve::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName )
{
uiTreeOrdering.skipRemainingChildren( true );
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -175,7 +221,7 @@ void RimWellLogDiffCurve::fieldChangedByUi( const caf::PdmFieldHandle* changedFi
{ {
if ( !m_wellLogCurveA() || !m_wellLogCurveB() ) return; if ( !m_wellLogCurveA() || !m_wellLogCurveB() ) return;
onLoadDataAndUpdate( false ); onLoadDataAndUpdate( true );
} }
} }
@ -204,25 +250,6 @@ QList<caf::PdmOptionItemInfo> RimWellLogDiffCurve::calculateValueOptions( const
if ( !curve || curve == this ) continue; if ( !curve || curve == this ) continue;
options.push_back( caf::PdmOptionItemInfo( curve->curveName(), curve ) ); options.push_back( caf::PdmOptionItemInfo( curve->curveName(), curve ) );
} }
// for ( const auto* wellLogPlot : wellLogPlotCollection->descendantsOfType<>() )
//{
// if ( !wellLogPlot ) continue;
// // Retrieve each track in plot
// // Note: How to get all RimWellLogTracks - not based on visibility?
// for ( auto* rimPlot : wellLogPlot->plots() )
// {
// RimWellLogTrack* plot = dynamic_cast<RimWellLogTrack*>( rimPlot );
// if ( !plot ) continue;
// // Extract each curve in track
// for ( RimWellLogCurve* curve : plot->curves() )
// {
// options.push_back( caf::PdmOptionItemInfo( curve->uiName(), curve ) );
// }
// }
//}
} }
return options; return options;
} }

View File

@ -47,6 +47,7 @@ public:
protected: protected:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
@ -55,6 +56,8 @@ private:
virtual QString createCurveAutoName() override; virtual QString createCurveAutoName() override;
virtual void onLoadDataAndUpdate( bool updateParentPlot ) override; virtual void onLoadDataAndUpdate( bool updateParentPlot ) override;
void setAutomaticName();
private: private:
caf::PdmPtrField<RimCase*> m_case; caf::PdmPtrField<RimCase*> m_case;