From 15b4077876b8abb9285e000aca62c4f77448397c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 24 Sep 2021 12:21:16 +0200 Subject: [PATCH] Fix some minor issues (#8043) * #8016 Surface Ensemble : Update 2d intersection views * Ensemble WLP : Make code more robust to missing data * Janitor: Do not add files to recently used list when importing ensemble * #8016 Ensemble WLP : Delete all temporary plots in one go * #8016 WLP: Create a default date string that can be exported to LAS * #8016 Janitor: Use *.dev as default well path extension --- .../RicCreateEnsembleWellLogFeature.cpp | 16 ++++-- .../Commands/RicCreateEnsembleWellLogUi.cpp | 26 ++++++++-- .../Commands/RicCreateEnsembleWellLogUi.h | 5 +- .../Commands/RicImportGeneralDataFeature.cpp | 1 - .../Surfaces/RimSurfaceCollection.cpp | 12 +++++ .../WellLog/Rim3dWellLogExtractionCurve.cpp | 29 +---------- .../WellLog/RimEnsembleWellLogStatistics.cpp | 35 +++++++------ .../WellLog/RimWellLogExtractionCurve.cpp | 52 +++++++++++-------- .../WellLog/RimWellLogExtractionCurve.h | 2 + .../WellLog/RimWellLogFileCurve.cpp | 11 ++-- 10 files changed, 110 insertions(+), 79 deletions(-) diff --git a/ApplicationLibCode/Commands/RicCreateEnsembleWellLogFeature.cpp b/ApplicationLibCode/Commands/RicCreateEnsembleWellLogFeature.cpp index 2cb6d3f48d..2bba36fb7e 100644 --- a/ApplicationLibCode/Commands/RicCreateEnsembleWellLogFeature.cpp +++ b/ApplicationLibCode/Commands/RicCreateEnsembleWellLogFeature.cpp @@ -146,7 +146,8 @@ void RicCreateEnsembleWellLogFeature::executeCommand( const RicCreateEnsembleWel if ( !wellPath ) return; - QStringList allLasFileNames; + std::vector tmpPlotsToDelete; + QStringList allLasFileNames; for ( const auto& fileName : fileNames ) { auto task = progress.task( QString( "Extracting well log for %1" ).arg( fileName ) ); @@ -217,12 +218,21 @@ void RicCreateEnsembleWellLogFeature::executeCommand( const RicCreateEnsembleWel allLasFileNames << lasFile; } - // Remove the temporary plots after export - plotCollection->removePlot( wellLogPlot ); + tmpPlotsToDelete.push_back( wellLogPlot ); RicCloseCaseFeature::deleteEclipseCase( eclipseCase ); } + for ( auto wlp : tmpPlotsToDelete ) + { + // Hide window to avoid flickering + wlp->setShowWindow( false ); + wlp->updateMdiWindowVisibility(); + + plotCollection->removePlot( wlp ); + delete wlp; + } + if ( ui.autoCreateEnsembleWellLogs() ) { std::vector ensembleWellLogs = diff --git a/ApplicationLibCode/Commands/RicCreateEnsembleWellLogUi.cpp b/ApplicationLibCode/Commands/RicCreateEnsembleWellLogUi.cpp index b94198b858..9875e8c09d 100644 --- a/ApplicationLibCode/Commands/RicCreateEnsembleWellLogUi.cpp +++ b/ApplicationLibCode/Commands/RicCreateEnsembleWellLogUi.cpp @@ -32,6 +32,7 @@ #include "cafAppEnum.h" #include "cafPdmObject.h" #include "cafPdmUiCheckBoxEditor.h" +#include "cafPdmUiFilePathEditor.h" #include "cafPdmUiListEditor.h" #include "cafPdmUiOrdering.h" #include "cafPdmUiTreeSelectionEditor.h" @@ -68,7 +69,7 @@ RicCreateEnsembleWellLogUi::RicCreateEnsembleWellLogUi() CAF_PDM_InitField( &m_timeStep, "TimeStep", 0, "Time Step", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_wellPathSource, "WellPathSource", "Well Path Source", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_wellPath, "WellPath", "Well Path", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_well, "Well", "Well", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellFilePath, "WellFilePath", "Well File Path", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_selectedKeywords, "SelectedProperties", "Selected Properties", "", "", "" ); m_selectedKeywords.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() ); @@ -101,9 +102,9 @@ void RicCreateEnsembleWellLogUi::defineUiOrdering( QString uiConfigName, caf::Pd uiOrdering.add( &m_wellPathSource ); bool fileSource = ( m_wellPathSource == RicCreateEnsembleWellLogUi::WellPathSource::FILE ); - uiOrdering.add( &m_well ); + uiOrdering.add( &m_wellFilePath ); uiOrdering.add( &m_wellPath ); - m_well.uiCapability()->setUiHidden( !fileSource ); + m_wellFilePath.uiCapability()->setUiHidden( !fileSource ); m_wellPath.uiCapability()->setUiHidden( fileSource ); uiOrdering.add( &m_autoCreateEnsembleWellLogs ); } @@ -164,6 +165,23 @@ QList return options; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCreateEnsembleWellLogUi::defineEditorAttribute( const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute ) +{ + if ( field == &m_wellFilePath ) + { + auto* myAttr = dynamic_cast( attribute ); + if ( myAttr ) + { + myAttr->m_fileSelectionFilter = "Well Path Files(*.dev);;All Files (*.*)"; + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -225,7 +243,7 @@ int RicCreateEnsembleWellLogUi::timeStep() const //-------------------------------------------------------------------------------------------------- QString RicCreateEnsembleWellLogUi::wellPathFilePath() const { - return m_well().path(); + return m_wellFilePath().path(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/RicCreateEnsembleWellLogUi.h b/ApplicationLibCode/Commands/RicCreateEnsembleWellLogUi.h index 50c432e7f9..3fa77a06ec 100644 --- a/ApplicationLibCode/Commands/RicCreateEnsembleWellLogUi.h +++ b/ApplicationLibCode/Commands/RicCreateEnsembleWellLogUi.h @@ -68,11 +68,14 @@ protected: QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) override; + void defineEditorAttribute( const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute ) override; std::vector validResultCategories() const; private: - caf::PdmField m_well; + caf::PdmField m_wellFilePath; caf::PdmField> m_wellPathSource; caf::PdmPtrField m_wellPath; caf::PdmField m_autoCreateEnsembleWellLogs; diff --git a/ApplicationLibCode/Commands/RicImportGeneralDataFeature.cpp b/ApplicationLibCode/Commands/RicImportGeneralDataFeature.cpp index 5deb9ee50b..eb2e69e7d5 100644 --- a/ApplicationLibCode/Commands/RicImportGeneralDataFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportGeneralDataFeature.cpp @@ -240,7 +240,6 @@ bool RicImportGeneralDataFeature::openEclipseCaseFromFileNames( const QStringLis { for ( const auto& newCaseFileAndId : newCaseFiles ) { - RiaApplication::instance()->addToRecentFiles( newCaseFileAndId.first ); createdCaseIds.push_back( newCaseFileAndId.second ); } return true; diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.cpp b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.cpp index f31d85bf02..26b2734666 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.cpp @@ -21,6 +21,9 @@ #include "RiaColorTables.h" #include "RiaLogging.h" +#include "Rim2dIntersectionView.h" +#include "Rim2dIntersectionViewCollection.h" +#include "RimCase.h" #include "RimEnsembleSurface.h" #include "RimFileSurface.h" #include "RimGridCaseSurface.h" @@ -333,6 +336,15 @@ void RimSurfaceCollection::updateViews( const std::vector& surfsToR for ( auto view : viewsNeedingUpdate ) { view->scheduleCreateDisplayModelAndRedraw(); + + if ( view->ownerCase() ) + { + auto views = view->ownerCase()->intersectionViewCollection()->views(); + for ( Rim2dIntersectionView* view : views ) + { + view->scheduleCreateDisplayModelAndRedraw(); + } + } } } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogExtractionCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogExtractionCurve.cpp index e1dc116a32..8ca00a2701 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogExtractionCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/Rim3dWellLogExtractionCurve.cpp @@ -530,32 +530,5 @@ void Rim3dWellLogExtractionCurve::initAfterRead() //-------------------------------------------------------------------------------------------------- QString Rim3dWellLogExtractionCurve::wellDate() const { - RimGeoMechCase* geomCase = dynamic_cast( m_case.value() ); - RimEclipseCase* eclipseCase = dynamic_cast( m_case.value() ); - - QStringList timeStepNames; - - if ( eclipseCase ) - { - if ( m_eclipseResultDefinition->resultType() == RiaDefines::ResultCatType::STATIC_NATIVE ) - { - return QString(); - } - if ( eclipseCase->eclipseCaseData() ) - { - timeStepNames = eclipseCase->timeStepStrings(); - } - } - else if ( geomCase ) - { - if ( geomCase->geoMechData() ) - { - timeStepNames = geomCase->timeStepStrings(); - } - } - if ( m_timeStep == -1 ) - { - return QString( "Animation Time Step" ); - } - return ( m_timeStep >= 0 && m_timeStep < timeStepNames.size() ) ? timeStepNames[m_timeStep] : ""; + return RimWellLogExtractionCurve::wellDateFromGridCaseModel( m_case, m_timeStep ); } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogStatistics.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogStatistics.cpp index 932ccd9ad8..ecff983772 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogStatistics.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimEnsembleWellLogStatistics.cpp @@ -183,28 +183,29 @@ void RimEnsembleWellLogStatistics::calculateByKLayer( const std::vector kIndexValues = fileData->values( RiaResultNames::indexKResultName() ); std::vector values = fileData->values( wellLogChannelName ); - CAF_ASSERT( values.size() == kIndexValues.size() ); - - std::set seenTopIndexes; - std::set seenBottomIndexes; - - for ( size_t i = 0; i < values.size(); i++ ) + if ( values.size() == kIndexValues.size() ) { - int kLayer = static_cast( kIndexValues[i] ); - if ( seenTopIndexes.count( kLayer ) == 0 ) + std::set seenTopIndexes; + std::set seenBottomIndexes; + + for ( size_t i = 0; i < values.size(); i++ ) { - seenTopIndexes.insert( kLayer ); - topValues[kLayer].push_back( values[i] ); + int kLayer = static_cast( kIndexValues[i] ); + if ( seenTopIndexes.count( kLayer ) == 0 ) + { + seenTopIndexes.insert( kLayer ); + topValues[kLayer].push_back( values[i] ); + } } - } - for ( int i = static_cast( values.size() ) - 1; i >= 0; i-- ) - { - int kLayer = static_cast( kIndexValues[i] ); - if ( seenBottomIndexes.count( kLayer ) == 0 ) + for ( int i = static_cast( values.size() ) - 1; i >= 0; i-- ) { - seenBottomIndexes.insert( kLayer ); - bottomValues[kLayer].push_back( values[i] ); + int kLayer = static_cast( kIndexValues[i] ); + if ( seenBottomIndexes.count( kLayer ) == 0 ) + { + seenBottomIndexes.insert( kLayer ); + bottomValues[kLayer].push_back( values[i] ); + } } } } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurve.cpp index 9642b75b33..9e043dd2c5 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurve.cpp @@ -614,6 +614,36 @@ RiaDefines::PhaseType RimWellLogExtractionCurve::phaseType() const return phase; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimWellLogExtractionCurve::wellDateFromGridCaseModel( RimCase* gridCaseModel, int timeStep ) +{ + auto* geomCase = dynamic_cast( gridCaseModel ); + auto* eclipseCase = dynamic_cast( gridCaseModel ); + + QStringList timeStepNames; + + if ( eclipseCase ) + { + if ( eclipseCase->eclipseCaseData() ) + { + timeStepNames = eclipseCase->timeStepStrings(); + } + } + else if ( geomCase ) + { + if ( geomCase->geoMechData() ) + { + timeStepNames = geomCase->timeStepStrings(); + } + } + + if ( timeStep >= 0 && timeStep < timeStepNames.size() ) return timeStepNames[timeStep]; + + return "01_Jan_2000"; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -975,27 +1005,7 @@ QString RimWellLogExtractionCurve::wellName() const //-------------------------------------------------------------------------------------------------- QString RimWellLogExtractionCurve::wellDate() const { - RimGeoMechCase* geomCase = dynamic_cast( m_case.value() ); - RimEclipseCase* eclipseCase = dynamic_cast( m_case.value() ); - - QStringList timeStepNames; - - if ( eclipseCase ) - { - if ( eclipseCase->eclipseCaseData() ) - { - timeStepNames = eclipseCase->timeStepStrings(); - } - } - else if ( geomCase ) - { - if ( geomCase->geoMechData() ) - { - timeStepNames = geomCase->timeStepStrings(); - } - } - - return ( m_timeStep >= 0 && m_timeStep < timeStepNames.size() ) ? timeStepNames[m_timeStep] : ""; + return RimWellLogExtractionCurve::wellDateFromGridCaseModel( m_case(), m_timeStep ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurve.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurve.h index 5fe6860d3e..42129a11a1 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurve.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurve.h @@ -94,6 +94,8 @@ public: void setAutoNameComponents( bool addCaseName, bool addProperty, bool addWellname, bool addTimeStep, bool addDate ); RiaDefines::PhaseType phaseType() const override; + static QString wellDateFromGridCaseModel( RimCase* gridCaseModel, int timeStep ); + protected: QString createCurveAutoName() override; void onLoadDataAndUpdate( bool updateParentPlot ) override; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileCurve.cpp index e8aac5c81e..68fa65a608 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileCurve.cpp @@ -100,11 +100,14 @@ void RimWellLogFileCurve::onLoadDataAndUpdate( bool updateParentPlot ) { // Adjust depths by reassigning depths for top and bottom of layer for each K layer std::vector kIndexValues = wellLogFile->values( RiaResultNames::indexKResultName() ); - auto [valuesAdjusted, measuredDepthValuesAdjusted] = - adjustByIndexDepthOffsets( measuredDepthValues, values, kIndexValues ); + if ( values.size() == kIndexValues.size() ) + { + auto [valuesAdjusted, measuredDepthValuesAdjusted] = + adjustByIndexDepthOffsets( measuredDepthValues, values, kIndexValues ); - values = valuesAdjusted; - measuredDepthValues = measuredDepthValuesAdjusted; + values = valuesAdjusted; + measuredDepthValues = measuredDepthValuesAdjusted; + } } if ( tvdMslValues.size() != values.size() )