mirror of
https://github.com/OPM/ResInsight.git
synced 2026-08-27 13:47:12 -05:00
#13963 Well path: Fix empty file path after reopening JSON-imported well paths
Remove the SSIHUB cache mechanism (m_filePathInCache, isStoredInCache, setupBeforeSave, updateFilePathsFromProjectPath) from RimFileWellPath. The cache path was triggered whenever the well path's id field was non-empty, which JSON imports populate, causing m_filePath to be cleared on save.
This commit is contained in:
@@ -56,7 +56,6 @@
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimEclipseViewCollection.h"
|
||||
#include "RimEnsembleWellLogsCollection.h"
|
||||
#include "RimFileWellPath.h"
|
||||
#include "RimFlowPlotCollection.h"
|
||||
#include "RimFractureTemplate.h"
|
||||
#include "RimFractureTemplateCollection.h"
|
||||
@@ -555,17 +554,6 @@ void RimProject::setProjectFileNameAndUpdateDependencies( const QString& project
|
||||
}
|
||||
|
||||
if ( ensembleFileSetCollection() ) ensembleFileSetCollection()->updateFilePathsFromProjectPath( newProjectPath, oldProjectPath );
|
||||
|
||||
if ( auto* wellPathColl = RimWellPathCollection::instance() )
|
||||
{
|
||||
for ( auto wellPath : wellPathColl->allWellPaths() )
|
||||
{
|
||||
if ( auto fileWellPath = dynamic_cast<RimFileWellPath*>( wellPath ) )
|
||||
{
|
||||
fileWellPath->updateFilePathsFromProjectPath( oldProjectPath, newProjectPath );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -5,13 +5,9 @@
|
||||
#include "RifWellPathImporter.h"
|
||||
|
||||
#include "RimProject.h"
|
||||
#include "RimTools.h"
|
||||
|
||||
#include "cafUtils.h"
|
||||
|
||||
#include "QDir"
|
||||
#include "QFileInfo"
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimFileWellPath, "WellPath" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -42,8 +38,6 @@ RimFileWellPath::RimFileWellPath()
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_filePath, "WellPathFilepath", "File Path" );
|
||||
m_filePath.uiCapability()->setUiReadOnly( true );
|
||||
CAF_PDM_InitFieldNoDefault( &m_filePathInCache, "WellPathFilePathInCache", "File Name" );
|
||||
m_filePathInCache.uiCapability()->setUiReadOnly( true );
|
||||
|
||||
CAF_PDM_InitField( &m_wellPathIndexInFile, "WellPathNumberInFile", -1, "Well Number in File" );
|
||||
m_wellPathIndexInFile.uiCapability()->setUiReadOnly( true );
|
||||
@@ -63,14 +57,7 @@ RimFileWellPath::~RimFileWellPath()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimFileWellPath::filePath() const
|
||||
{
|
||||
if ( isStoredInCache() || m_filePath().path().isEmpty() )
|
||||
{
|
||||
return m_filePathInCache().path();
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_filePath().path();
|
||||
}
|
||||
return m_filePath().path();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -119,16 +106,7 @@ void RimFileWellPath::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering
|
||||
uiOrdering.add( &m_useAutoGeneratedPointAtSeaLevel );
|
||||
|
||||
caf::PdmUiGroup* fileInfoGroup = uiOrdering.createGroupBeforeGroup( "Simulation Well", "File" );
|
||||
|
||||
if ( isStoredInCache() )
|
||||
{
|
||||
fileInfoGroup->add( &m_filePathInCache );
|
||||
}
|
||||
else
|
||||
{
|
||||
fileInfoGroup->add( &m_filePath );
|
||||
}
|
||||
|
||||
fileInfoGroup->add( &m_filePath );
|
||||
fileInfoGroup->add( &m_wellPathIndexInFile );
|
||||
|
||||
if ( !id().isEmpty() ) uiOrdering.insertBeforeItem( m_datumElevation.uiCapability(), &id );
|
||||
@@ -174,16 +152,6 @@ bool RimFileWellPath::readWellPathFile( QString* errorMessage, RifWellPathImport
|
||||
|
||||
setWellPathGeometry( wellData.m_wellPathGeometry.p() );
|
||||
|
||||
// Now that the data is read, we know if this is an SSIHUB wellpath that needs to be stored in the
|
||||
// cache folder along with the project file. If it is, move the pathfile reference to the m_filePathInCache
|
||||
// in order to avoid it being handled as an externalFilePath by the RimProject class
|
||||
|
||||
if ( isStoredInCache() && !m_filePath().path().isEmpty() )
|
||||
{
|
||||
m_filePathInCache = m_filePath().path();
|
||||
m_filePath = QString( "" );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -193,95 +161,6 @@ bool RimFileWellPath::readWellPathFile( QString* errorMessage, RifWellPathImport
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimFileWellPath::getCacheDirectoryPath()
|
||||
{
|
||||
QString cacheDirPath = RimTools::getCacheRootDirectoryPathFromProject();
|
||||
cacheDirPath += "_wellpaths";
|
||||
return cacheDirPath;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimFileWellPath::getCacheFileName()
|
||||
{
|
||||
if ( m_filePathInCache().path().isEmpty() )
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
QString cacheFileName;
|
||||
|
||||
// Make the path correct related to the possibly new project filename
|
||||
|
||||
QString newCacheDirPath = getCacheDirectoryPath();
|
||||
QFileInfo oldCacheFile( m_filePathInCache().path() );
|
||||
|
||||
cacheFileName = newCacheDirPath + "/" + oldCacheFile.fileName();
|
||||
|
||||
return cacheFileName;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFileWellPath::setupBeforeSave()
|
||||
{
|
||||
// Copy the possibly "cached" SSIHUB wellpath, stored in the folder along the project file
|
||||
// SSIHUB is the only source for populating Id, use text in this field to decide if the cache file must be copied to
|
||||
// new project cache location
|
||||
if ( !isStoredInCache() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( m_filePathInCache().path().isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QDir::root().mkpath( getCacheDirectoryPath() );
|
||||
|
||||
QString newCacheFileName = getCacheFileName();
|
||||
|
||||
// Use QFileInfo to get same string representation to avoid issues with mix of forward and backward slashes
|
||||
QFileInfo prevFileInfo( m_filePathInCache().path() );
|
||||
QFileInfo currentFileInfo( newCacheFileName );
|
||||
|
||||
if ( prevFileInfo.absoluteFilePath().compare( currentFileInfo.absoluteFilePath() ) != 0 )
|
||||
{
|
||||
QFile::copy( m_filePathInCache().path(), newCacheFileName );
|
||||
|
||||
m_filePathInCache = newCacheFileName;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimFileWellPath::isStoredInCache() const
|
||||
{
|
||||
// SSIHUB is the only source for populating Id, use text in this field to decide if the cache file must be copied to
|
||||
// new project cache location
|
||||
return !id().isEmpty();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFileWellPath::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath )
|
||||
{
|
||||
QString newCacheFileName = getCacheFileName();
|
||||
|
||||
if ( caf::Utils::fileExists( newCacheFileName ) )
|
||||
{
|
||||
m_filePathInCache = newCacheFileName;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -26,13 +26,11 @@ public:
|
||||
RimFileWellPath();
|
||||
~RimFileWellPath() override;
|
||||
|
||||
QString filePath() const;
|
||||
void setFilepath( const QString& path );
|
||||
bool readWellPathFile( QString* errorMessage, RifWellPathImporter* wellPathImporter, bool setWellNameForExport );
|
||||
int wellPathIndexInFile() const; // -1 means none.
|
||||
void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath );
|
||||
void setWellPathIndexInFile( int index );
|
||||
static QString getCacheDirectoryPath();
|
||||
QString filePath() const;
|
||||
void setFilepath( const QString& path );
|
||||
bool readWellPathFile( QString* errorMessage, RifWellPathImporter* wellPathImporter, bool setWellNameForExport );
|
||||
int wellPathIndexInFile() const; // -1 means none.
|
||||
void setWellPathIndexInFile( int index );
|
||||
|
||||
protected:
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
@@ -40,15 +38,10 @@ protected:
|
||||
private:
|
||||
QString surveyType() { return m_surveyType; }
|
||||
void setSurveyType( QString surveyType );
|
||||
bool isStoredInCache() const;
|
||||
QString getCacheFileName();
|
||||
|
||||
void setupBeforeSave() override;
|
||||
|
||||
void ensureWellPathStartAtSeaLevel( RigWellPath* wellPath );
|
||||
|
||||
caf::PdmField<caf::FilePath> m_filePath;
|
||||
caf::PdmField<caf::FilePath> m_filePathInCache; // Used for SSIHUB imported well paths
|
||||
caf::PdmField<int> m_wellPathIndexInFile; // -1 means none.
|
||||
|
||||
caf::PdmField<QString> id;
|
||||
|
||||
Reference in New Issue
Block a user