Well path import improvements

* #9432 Clean file cache when all wells are deleted
* Key Events: Avoid eating Delete key events 
Do not use a key short cut on menu actions that are always enabled. Will eat events from other actions.

* #9433 Well Path Import: Keep prefix when trying to match existing well path
This commit is contained in:
Magne Sjaastad 2022-11-04 10:11:08 +01:00 committed by GitHub
parent 68c72c85cf
commit f77b3673b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 23 deletions

View File

@ -18,6 +18,8 @@
#include "RicDeleteSubPlotCtxFeature.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicDeleteSubPlotCtxFeature, "RicDeleteSubPlotCtxFeature" );
//--------------------------------------------------------------------------------------------------
@ -27,3 +29,12 @@ bool RicDeleteSubPlotCtxFeature::isCommandEnabled()
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicDeleteSubPlotCtxFeature::setupActionLook( QAction* actionToSetup )
{
RicDeleteSubPlotFeature::setupActionLook( actionToSetup );
actionToSetup->setShortcut( QKeySequence() );
}

View File

@ -29,4 +29,5 @@ class RicDeleteSubPlotCtxFeature : public RicDeleteSubPlotFeature
protected:
bool isCommandEnabled() override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@ -55,21 +55,23 @@ public:
WellData readWellData( const QString& filePath, size_t indexInFile );
WellData readWellData( const QString& filePath );
WellMetaData readWellMetaData( const QString& filePath, size_t indexInFile );
WellMetaData readWellMetaData( const QString& filePath );
size_t wellDataCount( const QString& filePath );
void clear();
void removeFilePath( const QString& filePath );
static WellMetaData readWellMetaData( const QString& filePath, size_t indexInFile );
static WellMetaData readWellMetaData( const QString& filePath );
private:
WellData readJsonWellData( const QString& filePath );
WellMetaData readJsonWellMetaData( const QString& filePath );
WellData readAsciiWellData( const QString& filePath, size_t indexInFile );
WellMetaData readAsciiWellMetaData( const QString& filePath, size_t indexInFile );
void readAllAsciiWellData( const QString& filePath );
inline bool isJsonFile( const QString& filePath );
static WellData readJsonWellData( const QString& filePath );
static WellMetaData readJsonWellMetaData( const QString& filePath );
static WellMetaData readAsciiWellMetaData( const QString& filePath, size_t indexInFile );
static bool isJsonFile( const QString& filePath );
private:
std::map<QString, std::vector<RifWellPathImporter::WellData>> m_fileNameToWellDataGroupMap;
};

View File

@ -305,16 +305,17 @@ void RimWellPathCollection::readAndAddWellPaths( std::vector<RimFileWellPath*>&
caf::ProgressInfo progress( wellPathArray.size(), "Reading well paths from file" );
std::vector<RimWellPath*> wellPathsToGroup;
for ( size_t wpIdx = 0; wpIdx < wellPathArray.size(); wpIdx++ )
for ( RimFileWellPath* wellPath : wellPathArray )
{
RimFileWellPath* wellPath = wellPathArray[wpIdx];
wellPath->readWellPathFile( nullptr, m_wellPathImporter.get(), true );
progress.setProgressDescription( QString( "Reading file %1" ).arg( wellPath->name() ) );
// If a well path with this name exists already, make it read the well path file
RimFileWellPath* existingWellPath = dynamic_cast<RimFileWellPath*>( tryFindMatchingWellPath( wellPath->name() ) );
// If a well path with this name exists already, make it read the well path file. This is useful if a well log
// file has been imported before a well path file containing the full geometry for the well path.
// NB! Do not use tryFindMatchingWellPath(), as this function will remove the prefix and will return an false
// match in many cases.
auto* existingWellPath = dynamic_cast<RimFileWellPath*>( wellPathByName( wellPath->name() ) );
if ( existingWellPath )
{
existingWellPath->setFilepath( wellPath->filePath() );
@ -584,6 +585,8 @@ void RimWellPathCollection::deleteAllWellPaths()
//--------------------------------------------------------------------------------------------------
void RimWellPathCollection::deleteWell( RimWellPath* wellPath )
{
removeWellPath( wellPath );
m_wellPaths.removeChild( wellPath );
delete wellPath;
}
@ -703,16 +706,18 @@ void RimWellPathCollection::reloadAllWellPathFormations()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathCollection::removeWellPath( gsl::not_null<RimWellPath*> wellPath )
void RimWellPathCollection::removeWellPath( gsl::not_null<RimWellPath*> wellToRemove )
{
RimFileWellPath* fileWellPath = dynamic_cast<RimFileWellPath*>( wellPath.get() );
if ( fileWellPath )
auto* fileWellToRemove = dynamic_cast<RimFileWellPath*>( wellToRemove.get() );
if ( fileWellToRemove )
{
bool isFilePathUsed = false;
for ( auto wellPath : m_wellPaths )
for ( const auto& well : m_wellPaths )
{
RimFileWellPath* fWPath = dynamic_cast<RimFileWellPath*>( wellPath.p() );
if ( fWPath && fWPath->filePath() == fileWellPath->filePath() )
auto fileWell = dynamic_cast<RimFileWellPath*>( well.p() );
if ( fileWell == fileWellToRemove ) continue;
if ( fileWell && fileWell->filePath() == fileWellToRemove->filePath() )
{
isFilePathUsed = true;
break;
@ -723,7 +728,7 @@ void RimWellPathCollection::removeWellPath( gsl::not_null<RimWellPath*> wellPath
{
// One file can have multiple well paths
// If no other well paths are referencing the filepath, remove cached data from the file reader
m_wellPathImporter->removeFilePath( fileWellPath->filePath() );
m_wellPathImporter->removeFilePath( fileWellToRemove->filePath() );
}
}
updateAllRequiredEditors();