diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimImportedWellLog.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimImportedWellLog.cpp index d7a7beaf8d..00e63b5d11 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimImportedWellLog.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimImportedWellLog.cpp @@ -38,7 +38,7 @@ CAF_PDM_SOURCE_INIT( RimImportedWellLog, "ImportedWellLog" ); //-------------------------------------------------------------------------------------------------- RimImportedWellLog::RimImportedWellLog() { - CAF_PDM_InitScriptableObject( "Imported Well Log", ":/LasFile16x16.png", "", "ImportedWellLog" ); + CAF_PDM_InitScriptableObject( "Imported Well Log", ":/WellLogFile.svg", "", "ImportedWellLog" ); CAF_PDM_InitScriptableField( &m_name, "Name", QString(), "Name" ); m_name.uiCapability()->setUiReadOnly( true ); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp index 775e22e4f9..2edc897082 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimOsduWellLog.cpp @@ -38,7 +38,7 @@ CAF_PDM_SOURCE_INIT( RimOsduWellLog, "OsduWellLog" ); //-------------------------------------------------------------------------------------------------- RimOsduWellLog::RimOsduWellLog() { - CAF_PDM_InitScriptableObject( "OSDU Well Log", ":/LasFile16x16.png" ); + CAF_PDM_InitScriptableObject( "OSDU Well Log", ":/WellLogFile.svg" ); CAF_PDM_InitScriptableFieldNoDefault( &m_name, "Name", "" ); m_name.uiCapability()->setUiReadOnly( true ); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLog.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLog.cpp index 050538fbfc..0d484fcfe0 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLog.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLog.cpp @@ -45,7 +45,7 @@ const QDateTime RimWellLog::DEFAULT_DATE_TIME = RiaQDateTimeTools::createUtcDate //-------------------------------------------------------------------------------------------------- RimWellLog::RimWellLog() { - CAF_PDM_InitScriptableObject( "Well File Info", ":/LasFile16x16.png" ); + CAF_PDM_InitScriptableObject( "Well File Info", ":/WellLogFile.svg" ); CAF_PDM_InitFieldNoDefault( &m_date, "Date", "Date" ); m_date.uiCapability()->setAttribute( caf::PdmUiDateEditor::Keys::DATE_FORMAT, RiaQDateTimeTools::dateFormatString() ); @@ -88,11 +88,25 @@ void RimWellLog::fieldChangedByUi( const caf::PdmFieldHandle* changedField, cons //-------------------------------------------------------------------------------------------------- void RimWellLog::updateChannelsFromWellLogData( RigWellLogData* wellLogData ) { - m_wellLogChannels.deleteChildren(); - - if ( !wellLogData ) return; + if ( !wellLogData ) + { + m_wellLogChannels.deleteChildren(); + return; + } QStringList wellLogNames = wellLogData->wellLogChannelNames(); + + // Keep existing channel objects when the names are unchanged, to avoid stale entries in the project tree + // when a file is read several times + QStringList existingNames; + for ( const auto* channel : wellLogChannels() ) + { + existingNames.append( channel->name() ); + } + if ( existingNames == wellLogNames ) return; + + m_wellLogChannels.deleteChildren(); + for ( int logIdx = 0; logIdx < wellLogNames.size(); logIdx++ ) { RimWellLogChannel* wellLog = new RimWellLogChannel(); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogChannel.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogChannel.cpp index 05c1cf357e..4921add901 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogChannel.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogChannel.cpp @@ -28,7 +28,7 @@ CAF_PDM_SOURCE_INIT( RimWellLogChannel, "WellLogChannel", "WellLogFileChannel" ) //-------------------------------------------------------------------------------------------------- RimWellLogChannel::RimWellLogChannel() { - CAF_PDM_InitObject( "Well Log Channel" ); + CAF_PDM_InitObject( "Well Log Channel", ":/WellLogChannel.svg" ); RiaFieldHandleTools::disableWriteAndSetFieldHidden( nameField() ); } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCsvFile.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCsvFile.cpp index 939a8f8792..b38fd75fce 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCsvFile.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCsvFile.cpp @@ -40,7 +40,7 @@ CAF_PDM_SOURCE_INIT( RimWellLogCsvFile, "WellLogCsvFile" ); //-------------------------------------------------------------------------------------------------- RimWellLogCsvFile::RimWellLogCsvFile() { - CAF_PDM_InitObject( "Well CSV File Info", ":/LasFile16x16.png" ); + CAF_PDM_InitObject( "Well CSV File Info", ":/WellLogFile.svg" ); CAF_PDM_InitFieldNoDefault( &m_wellName, "WellName", "" ); m_wellName.uiCapability()->setUiReadOnly( true ); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp index 73cb1c9878..97c5a94e9c 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp @@ -135,31 +135,6 @@ RimWellLogCurveCommonDataSource::RimWellLogCurveCommonDataSource() CAF_PDM_InitFieldNoDefault( &m_rftSegmentBranchIndex, "SegmentBranchIndex", "RFT Branch" ); CAF_PDM_InitFieldNoDefault( &m_rftSegmentBranchType, "SegmentBranchType", "RFT Completion" ); - for ( caf::PdmFieldHandle* field : std::vector{ &m_case, - &m_summaryCase, - &m_simWellName, - &m_wellPath, - &m_timeStep, - &m_rftTimeStep, - &m_rftSegmentBranchIndex, - &m_rftWellName } ) - { - RiuTools::enableUpDownArrowsForComboBox( field ); - } - - auto setNextPreviousButtonTexts = []( caf::PdmFieldHandle* field, const QString& modifierText ) - { - field->uiCapability()->setAttribute( caf::PdmUiComboBoxEditor::Keys::NEXT_BUTTON_TEXT, "Next " + modifierText + "PgDown)" ); - field->uiCapability()->setAttribute( caf::PdmUiComboBoxEditor::Keys::PREV_BUTTON_TEXT, "Previous " + modifierText + "PgUp)" ); - }; - - setNextPreviousButtonTexts( &m_case, "(Shift+" ); - m_case.uiCapability()->setAttribute( caf::PdmUiComboBoxEditor::Keys::MINIMUM_CONTENTS_LENGTH, 14 ); - setNextPreviousButtonTexts( &m_wellPath, "(Ctrl+" ); - setNextPreviousButtonTexts( &m_simWellName, "(Ctrl+" ); - setNextPreviousButtonTexts( &m_timeStep, "(" ); - m_timeStep.uiCapability()->setAttribute( caf::PdmUiComboBoxEditor::Keys::MINIMUM_CONTENTS_LENGTH, 12 ); - m_case = nullptr; m_wellPath = nullptr; } @@ -835,6 +810,7 @@ void RimWellLogCurveCommonDataSource::applyNextTimeStep() std::vector RimWellLogCurveCommonDataSource::fieldsToShowInToolbar() { analyseCurvesAndTracks(); + updateComboBoxAttributes(); std::vector fieldsToDisplay; @@ -1058,12 +1034,72 @@ QList RimWellLogCurveCommonDataSource::calculateValueOpt return options; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogCurveCommonDataSource::updateComboBoxAttributes() +{ + struct FieldConfig + { + caf::PdmFieldHandle* field; + QString modifierText; // Empty if no custom button texts + int minimumContentsLength; // <= 0 if not set + }; + + const std::vector configs = { { &m_case, "(Shift+", 14 }, + { &m_summaryCase, "", 0 }, + { &m_simWellName, "(Ctrl+", 0 }, + { &m_wellPath, "(Ctrl+", 0 }, + { &m_timeStep, "(", 12 }, + { &m_rftTimeStep, "", 0 }, + { &m_rftSegmentBranchIndex, "", 0 }, + { &m_rftWellName, "", 0 } }; + + using Keys = caf::PdmUiComboBoxEditor::Keys; + + // Time step options are expensive to compute and exist whenever a case is set + auto hasOptions = [this]( const caf::PdmFieldHandle* field ) + { + if ( field == &m_timeStep ) return m_case() != nullptr; + return !calculateValueOptions( field ).isEmpty(); + }; + + for ( const auto& config : configs ) + { + auto* uiCapability = config.field->uiCapability(); + + // Fields without options are shown in a line editor, which does not support the combo box attributes + if ( !hasOptions( config.field ) ) + { + for ( const auto& key : { Keys::SHOW_PREVIOUS_AND_NEXT_BUTTONS, + Keys::NEXT_ICON, + Keys::PREVIOUS_ICON, + Keys::NEXT_BUTTON_TEXT, + Keys::PREV_BUTTON_TEXT, + Keys::MINIMUM_CONTENTS_LENGTH } ) + { + uiCapability->removeAttribute( key ); + } + continue; + } + + RiuTools::enableUpDownArrowsForComboBox( config.field ); + if ( !config.modifierText.isEmpty() ) + { + uiCapability->setAttribute( Keys::NEXT_BUTTON_TEXT, "Next " + config.modifierText + "PgDown)" ); + uiCapability->setAttribute( Keys::PREV_BUTTON_TEXT, "Previous " + config.modifierText + "PgUp)" ); + } + if ( config.minimumContentsLength > 0 ) uiCapability->setAttribute( Keys::MINIMUM_CONTENTS_LENGTH, config.minimumContentsLength ); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimWellLogCurveCommonDataSource::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { analyseCurvesAndTracks(); + updateComboBoxAttributes(); caf::PdmUiGroup* group = uiOrdering.addNewGroup( "Data Source" ); if ( m_case() ) group->add( &m_case ); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.h index 9c36820c6b..91b1e8384c 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.h @@ -88,6 +88,7 @@ public: void analyseCurvesAndTracks( const std::vector& curves, const std::vector& tracks ); void analyseCurvesAndTracks(); + void updateComboBoxAttributes(); void applyDataSourceChanges( const std::vector& curves, const std::vector& tracks ); void applyDataSourceChanges(); void applyPrevCase(); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.cpp index 51627b1d66..d4bbe7dab5 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFile.cpp @@ -30,7 +30,7 @@ CAF_PDM_ABSTRACT_SOURCE_INIT( RimWellLogFile, "WellLogFileInterface" ); //-------------------------------------------------------------------------------------------------- RimWellLogFile::RimWellLogFile() { - CAF_PDM_InitScriptableObject( "Well File Info", ":/LasFile16x16.png" ); + CAF_PDM_InitScriptableObject( "Well File Info", ":/WellLogFile.svg" ); CAF_PDM_InitScriptableFieldNoDefault( &m_fileName, "FileName", "Filename" ); m_fileName.uiCapability()->setUiReadOnly( true ); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.cpp index 90873057ef..24c2ac4035 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFile.cpp @@ -60,7 +60,7 @@ void caf::AppEnum::setUp() //-------------------------------------------------------------------------------------------------- RimWellLogLasFile::RimWellLogLasFile() { - CAF_PDM_InitScriptableObjectWithNameAndComment( "Well LAS File Info", ":/LasFile16x16.png", "", "", "WellLogLasFile", "" ); + CAF_PDM_InitScriptableObjectWithNameAndComment( "Well LAS File Info", ":/WellLogFile.svg", "", "", "WellLogLasFile", "" ); CAF_PDM_InitScriptableFieldNoDefault( &m_wellName, "WellName", "" ); m_wellName.uiCapability()->setUiReadOnly( true ); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFileCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFileCurve.cpp index 39b2dc1456..41d24aaf28 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFileCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogLasFileCurve.cpp @@ -83,17 +83,20 @@ void RimWellLogLasFileCurve::onLoadDataAndUpdate( bool updateParentPlot ) { auto wellLogPlot = firstAncestorOrThisOfTypeAsserted(); - if ( m_wellPath && m_wellLog ) + if ( m_wellLog ) { RigWellLogData* wellLogFile = m_wellLog->wellLogData(); if ( wellLogFile ) { + // The well path is optional. Without it, only depths from the LAS file are available + RigWellPath* rigWellPathGeometry = m_wellPath ? m_wellPath->wellPathGeometry() : nullptr; + std::vector values = wellLogFile->values( m_wellLogChannelName ); std::vector measuredDepthValues = wellLogFile->depthValues(); std::vector tvdMslValues = wellLogFile->tvdMslValues(); std::vector tvdRkbValues = wellLogFile->tvdRkbValues(); - bool rkbDiff = m_wellPath->wellPathGeometry() ? m_wellPath->wellPathGeometry()->rkbDiff() : 0.0; + double rkbDiff = rigWellPathGeometry ? rigWellPathGeometry->rkbDiff() : 0.0; if ( m_indexDepthOffsets ) { @@ -111,26 +114,24 @@ void RimWellLogLasFileCurve::onLoadDataAndUpdate( bool updateParentPlot ) if ( tvdMslValues.size() != values.size() ) { - RigWellPath* rigWellPath = m_wellPath->wellPathGeometry(); - if ( rigWellPath ) + if ( rigWellPathGeometry ) { tvdMslValues.clear(); for ( double measuredDepthValue : measuredDepthValues ) { - tvdMslValues.push_back( -rigWellPath->interpolatedPointAlongWellPath( measuredDepthValue ).z() ); + tvdMslValues.push_back( -rigWellPathGeometry->interpolatedPointAlongWellPath( measuredDepthValue ).z() ); } } } if ( tvdRkbValues.size() != values.size() ) { - RigWellPath* rigWellPath = m_wellPath->wellPathGeometry(); - if ( rigWellPath ) + if ( rigWellPathGeometry ) { tvdRkbValues.clear(); for ( double measuredDepthValue : measuredDepthValues ) { - tvdRkbValues.push_back( -rigWellPath->interpolatedPointAlongWellPath( measuredDepthValue ).z() + - m_wellPath->wellPathGeometry()->rkbDiff() ); + tvdRkbValues.push_back( -rigWellPathGeometry->interpolatedPointAlongWellPath( measuredDepthValue ).z() + + rigWellPathGeometry->rkbDiff() ); } } } @@ -222,7 +223,7 @@ std::pair, std::vector> auto findFirstIndex = []( int kLayer, const std::vector& vals ) { for ( size_t i = 0; i < vals.size(); i++ ) - if ( kLayer == static_cast( vals[i] ) ) return i; + if ( RigWellLogIndexDepthOffset::isValidKIndexValue( vals[i] ) && kLayer == static_cast( vals[i] ) ) return i; return vals.size(); }; @@ -230,7 +231,8 @@ std::pair, std::vector> auto findLastIndex = []( int kLayer, const std::vector& vals ) { for ( int i = static_cast( vals.size() ) - 1; i >= 0; i-- ) - if ( kLayer == static_cast( vals[i] ) ) return static_cast( i ); + if ( RigWellLogIndexDepthOffset::isValidKIndexValue( vals[i] ) && kLayer == static_cast( vals[i] ) ) + return static_cast( i ); return vals.size(); };