#5147 RimWellPath::m_wellPathFormationFilePath ->FilePath

RimFileWellPath::m_filepath ->FilePath
This commit is contained in:
Jacob Støren
2019-12-11 08:23:37 +01:00
parent 059288ef97
commit eb421db040
4 changed files with 48 additions and 43 deletions

View File

@@ -33,7 +33,7 @@ RimFileWellPath::RimFileWellPath()
m_surveyType.uiCapability()->setUiReadOnly( true ); m_surveyType.uiCapability()->setUiReadOnly( true );
m_surveyType.xmlCapability()->disableIO(); m_surveyType.xmlCapability()->disableIO();
CAF_PDM_InitField( &m_filepath, "WellPathFilepath", QString( "" ), "File Path", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_filepath, "WellPathFilepath", "File Path", "", "", "" );
m_filepath.uiCapability()->setUiReadOnly( true ); m_filepath.uiCapability()->setUiReadOnly( true );
CAF_PDM_InitField( &m_wellPathIndexInFile, "WellPathNumberInFile", -1, "Well Number in File", "", "", "" ); CAF_PDM_InitField( &m_wellPathIndexInFile, "WellPathNumberInFile", -1, "Well Number in File", "", "", "" );
m_wellPathIndexInFile.uiCapability()->setUiReadOnly( true ); m_wellPathIndexInFile.uiCapability()->setUiReadOnly( true );
@@ -49,7 +49,7 @@ RimFileWellPath::~RimFileWellPath() {}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QString RimFileWellPath::filepath() const QString RimFileWellPath::filepath() const
{ {
return m_filepath(); return m_filepath().path();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -112,10 +112,12 @@ void RimFileWellPath::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RimFileWellPath::readWellPathFile( QString* errorMessage, RifWellPathImporter* wellPathImporter ) bool RimFileWellPath::readWellPathFile( QString* errorMessage, RifWellPathImporter* wellPathImporter )
{ {
if ( caf::Utils::fileExists( m_filepath() ) ) if ( caf::Utils::fileExists( m_filepath().path() ) )
{ {
RifWellPathImporter::WellData wellData = wellPathImporter->readWellData( m_filepath(), m_wellPathIndexInFile() ); RifWellPathImporter::WellData wellData = wellPathImporter->readWellData( m_filepath().path(),
RifWellPathImporter::WellMetaData wellMetaData = wellPathImporter->readWellMetaData( m_filepath(), m_wellPathIndexInFile() );
RifWellPathImporter::WellMetaData wellMetaData = wellPathImporter->readWellMetaData( m_filepath().path(),
m_wellPathIndexInFile() ); m_wellPathIndexInFile() );
// General well info // General well info
@@ -132,7 +134,7 @@ bool RimFileWellPath::readWellPathFile( QString* errorMessage, RifWellPathImport
} }
else else
{ {
if ( errorMessage ) ( *errorMessage ) = "Could not find the well path file: " + m_filepath(); if ( errorMessage ) ( *errorMessage ) = "Could not find the well path file: " + m_filepath().path();
return false; return false;
} }
} }
@@ -152,7 +154,7 @@ QString RimFileWellPath::getCacheDirectoryPath()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QString RimFileWellPath::getCacheFileName() QString RimFileWellPath::getCacheFileName()
{ {
if ( m_filepath().isEmpty() ) if ( m_filepath().path().isEmpty() )
{ {
return ""; return "";
} }
@@ -161,7 +163,7 @@ QString RimFileWellPath::getCacheFileName()
// Make the path correct related to the possibly new project filename // Make the path correct related to the possibly new project filename
QString newCacheDirPath = getCacheDirectoryPath(); QString newCacheDirPath = getCacheDirectoryPath();
QFileInfo oldCacheFile( m_filepath ); QFileInfo oldCacheFile( m_filepath().path() );
cacheFileName = newCacheDirPath + "/" + oldCacheFile.fileName(); cacheFileName = newCacheDirPath + "/" + oldCacheFile.fileName();
@@ -179,7 +181,7 @@ void RimFileWellPath::setupBeforeSave()
return; return;
} }
if ( m_filepath().isEmpty() ) if ( m_filepath().path().isEmpty() )
{ {
return; return;
} }
@@ -189,12 +191,12 @@ void RimFileWellPath::setupBeforeSave()
QString newCacheFileName = getCacheFileName(); QString newCacheFileName = getCacheFileName();
// Use QFileInfo to get same string representation to avoid issues with mix of forward and backward slashes // Use QFileInfo to get same string representation to avoid issues with mix of forward and backward slashes
QFileInfo prevFileInfo( m_filepath ); QFileInfo prevFileInfo( m_filepath().path() );
QFileInfo currentFileInfo( newCacheFileName ); QFileInfo currentFileInfo( newCacheFileName );
if ( prevFileInfo.absoluteFilePath().compare( currentFileInfo.absoluteFilePath() ) != 0 ) if ( prevFileInfo.absoluteFilePath().compare( currentFileInfo.absoluteFilePath() ) != 0 )
{ {
QFile::copy( m_filepath, newCacheFileName ); QFile::copy( m_filepath().path(), newCacheFileName );
m_filepath = newCacheFileName; m_filepath = newCacheFileName;
} }
@@ -214,7 +216,7 @@ bool RimFileWellPath::isStoredInCache()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimFileWellPath::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) void RimFileWellPath::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath )
{ {
RimWellPath::updateFilePathsFromProjectPath( newProjectPath, oldProjectPath ); // RimWellPath::updateFilePathsFromProjectPath( newProjectPath, oldProjectPath );
if ( isStoredInCache() ) if ( isStoredInCache() )
{ {
@@ -225,8 +227,8 @@ void RimFileWellPath::updateFilePathsFromProjectPath( const QString& newProjectP
m_filepath = newCacheFileName; m_filepath = newCacheFileName;
} }
} }
else // else
{ // {
m_filepath = RimTools::relocateFile( m_filepath(), newProjectPath, oldProjectPath, nullptr, nullptr ); // m_filepath = RimTools::relocateFile( m_filepath(), newProjectPath, oldProjectPath, nullptr, nullptr );
} // }
} }

View File

@@ -45,8 +45,8 @@ private:
void setupBeforeSave() override; void setupBeforeSave() override;
caf::PdmField<QString> m_filepath; caf::PdmField<caf::FilePath> m_filepath;
caf::PdmField<int> m_wellPathIndexInFile; // -1 means none. caf::PdmField<int> m_wellPathIndexInFile; // -1 means none.
caf::PdmField<QString> id; caf::PdmField<QString> id;
caf::PdmField<QString> sourceSystem; caf::PdmField<QString> sourceSystem;

View File

@@ -118,7 +118,7 @@ RimWellPath::RimWellPath()
CAF_PDM_InitField( &m_formationKeyInFile, "WellPathFormationKeyInFile", QString( "" ), "Key in File", "", "", "" ); CAF_PDM_InitField( &m_formationKeyInFile, "WellPathFormationKeyInFile", QString( "" ), "Key in File", "", "", "" );
m_formationKeyInFile.uiCapability()->setUiReadOnly( true ); m_formationKeyInFile.uiCapability()->setUiReadOnly( true );
CAF_PDM_InitField( &m_wellPathFormationFilePath, "WellPathFormationFilePath", QString( "" ), "File Path", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_wellPathFormationFilePath, "WellPathFormationFilePath", "File Path", "", "", "" );
m_wellPathFormationFilePath.uiCapability()->setUiReadOnly( true ); m_wellPathFormationFilePath.uiCapability()->setUiReadOnly( true );
CAF_PDM_InitFieldNoDefault( &m_wellLogFile_OBSOLETE, "WellLogFile", "Well Log File", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_wellLogFile_OBSOLETE, "WellLogFile", "Well Log File", "", "", "" );
@@ -627,20 +627,20 @@ size_t RimWellPath::simulationWellBranchCount( const QString& simWellName )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellPath::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) void RimWellPath::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath )
{ {
{ //{
bool foundFile = false; // bool foundFile = false;
std::vector<QString> searchedPaths; // std::vector<QString> searchedPaths;
//
QString fileNameCandidate = RimTools::relocateFile( m_wellPathFormationFilePath, // QString fileNameCandidate = RimTools::relocateFile( m_wellPathFormationFilePath,
newProjectPath, // newProjectPath,
oldProjectPath, // oldProjectPath,
&foundFile, // &foundFile,
&searchedPaths ); // &searchedPaths );
if ( foundFile ) // if ( foundFile )
{ // {
m_wellPathFormationFilePath = fileNameCandidate; // m_wellPathFormationFilePath = fileNameCandidate;
} // }
} //}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -738,14 +738,14 @@ void RimWellPath::setFormationsGeometry( cvf::ref<RigWellPathFormations> wellPat
bool RimWellPath::readWellPathFormationsFile( QString* errorMessage, bool RimWellPath::readWellPathFormationsFile( QString* errorMessage,
RifWellPathFormationsImporter* wellPathFormationsImporter ) RifWellPathFormationsImporter* wellPathFormationsImporter )
{ {
if ( m_wellPathFormationFilePath().isEmpty() ) if ( m_wellPathFormationFilePath().path().isEmpty() )
{ {
return true; return true;
} }
if ( caf::Utils::fileExists( m_wellPathFormationFilePath() ) ) if ( caf::Utils::fileExists( m_wellPathFormationFilePath().path() ) )
{ {
m_wellPathFormations = wellPathFormationsImporter->readWellPathFormations( m_wellPathFormationFilePath(), m_wellPathFormations = wellPathFormationsImporter->readWellPathFormations( m_wellPathFormationFilePath().path(),
m_formationKeyInFile() ); m_formationKeyInFile() );
if ( m_name().isEmpty() ) if ( m_name().isEmpty() )
{ {
@@ -755,7 +755,8 @@ bool RimWellPath::readWellPathFormationsFile( QString* err
} }
else else
{ {
if ( errorMessage ) ( *errorMessage ) = "Could not find the well pick file: " + m_wellPathFormationFilePath(); if ( errorMessage )
( *errorMessage ) = "Could not find the well pick file: " + m_wellPathFormationFilePath().path();
return false; return false;
} }
} }
@@ -766,20 +767,21 @@ bool RimWellPath::readWellPathFormationsFile( QString* err
bool RimWellPath::reloadWellPathFormationsFile( QString* errorMessage, bool RimWellPath::reloadWellPathFormationsFile( QString* errorMessage,
RifWellPathFormationsImporter* wellPathFormationsImporter ) RifWellPathFormationsImporter* wellPathFormationsImporter )
{ {
if ( m_wellPathFormationFilePath().isEmpty() ) if ( m_wellPathFormationFilePath().path().isEmpty() )
{ {
return true; return true;
} }
if ( caf::Utils::fileExists( m_wellPathFormationFilePath() ) ) if ( caf::Utils::fileExists( m_wellPathFormationFilePath().path() ) )
{ {
m_wellPathFormations = wellPathFormationsImporter->reloadWellPathFormations( m_wellPathFormationFilePath(), m_wellPathFormations = wellPathFormationsImporter->reloadWellPathFormations( m_wellPathFormationFilePath().path(),
m_formationKeyInFile() ); m_formationKeyInFile() );
return true; return true;
} }
else else
{ {
if ( errorMessage ) ( *errorMessage ) = "Could not find the well pick file: " + m_wellPathFormationFilePath(); if ( errorMessage )
( *errorMessage ) = "Could not find the well pick file: " + m_wellPathFormationFilePath().path();
return false; return false;
} }
} }

View File

@@ -25,6 +25,7 @@
#include "RimWellPathComponentInterface.h" #include "RimWellPathComponentInterface.h"
#include "cafAppEnum.h" #include "cafAppEnum.h"
#include "cafFilePath.h"
#include "cafPdmChildField.h" #include "cafPdmChildField.h"
#include "cafPdmField.h" #include "cafPdmField.h"
#include "cafPdmObject.h" #include "cafPdmObject.h"
@@ -158,8 +159,8 @@ private:
caf::PdmField<RiaEclipseUnitTools::UnitSystemType> m_unitSystem; caf::PdmField<RiaEclipseUnitTools::UnitSystemType> m_unitSystem;
caf::PdmField<QString> m_wellPathFormationFilePath; caf::PdmField<caf::FilePath> m_wellPathFormationFilePath;
caf::PdmField<QString> m_formationKeyInFile; caf::PdmField<QString> m_formationKeyInFile;
caf::PdmField<bool> m_showWellPath; caf::PdmField<bool> m_showWellPath;
caf::PdmField<bool> m_showWellPathLabel; caf::PdmField<bool> m_showWellPathLabel;