Merge pull request #5246 from OPM/feature-external-file-reference-list-in-project-file

Feature: #5147 External file reference list in project file
This commit is contained in:
Jacob Støren 2019-12-18 15:47:50 +01:00 committed by GitHub
commit b01c4409f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
40 changed files with 499 additions and 210 deletions

View File

@ -316,7 +316,7 @@ bool RiaApplication::openFile( const QString& fileName )
} }
else if ( fileType & RiaDefines::ANY_ECLIPSE_FILE ) else if ( fileType & RiaDefines::ANY_ECLIPSE_FILE )
{ {
loadingSucceded = RicImportGeneralDataFeature::openEclipseFilesFromFileNames( QStringList{ fileName }, true ); loadingSucceded = RicImportGeneralDataFeature::openEclipseFilesFromFileNames( QStringList{fileName}, true );
lastUsedDialogTag = RiaDefines::defaultDirectoryLabel( fileType ); lastUsedDialogTag = RiaDefines::defaultDirectoryLabel( fileType );
} }
@ -701,7 +701,7 @@ bool RiaApplication::saveProjectAs( const QString& fileName, QString* errorMessa
onProjectBeingSaved(); onProjectBeingSaved();
if ( !m_project->writeFile() ) if ( !m_project->writeProjectFile() )
{ {
CAF_ASSERT( errorMessage ); CAF_ASSERT( errorMessage );
*errorMessage = QString( "Not possible to save project file. Make sure you have sufficient access " *errorMessage = QString( "Not possible to save project file. Make sure you have sufficient access "

View File

@ -218,7 +218,7 @@ std::vector<RigCompletionData> RicExportFractureCompletionsImpl::generateCompdat
{ {
std::vector<RigCompletionData> fractureCompletions; std::vector<RigCompletionData> fractureCompletions;
if ( !caseToApply || !caseToApply->eclipseCaseData() ) if ( !caseToApply || !caseToApply->eclipseCaseData() || !wellPathGeometry )
{ {
return fractureCompletions; return fractureCompletions;
} }

View File

@ -87,7 +87,7 @@ std::vector<RigCompletionData>
{ {
std::vector<RigCompletionData> completionData; std::vector<RigCompletionData> completionData;
if ( !wellPath || !wellPath->completions() ) if ( !wellPath || !wellPath->completions() || !wellPath->wellPathGeometry() )
{ {
return completionData; return completionData;
} }
@ -197,7 +197,7 @@ void RicFishbonesTransmissibilityCalculationFeatureImp::findFishboneLateralsWell
const RimWellPath* wellPath, const RimWellPath* wellPath,
const RicExportCompletionDataSettingsUi& settings ) const RicExportCompletionDataSettingsUi& settings )
{ {
if ( !wellPath ) return; if ( !wellPath || !wellPath->wellPathGeometry() ) return;
// Generate data // Generate data
const RigEclipseCaseData* caseData = settings.caseToApply()->eclipseCaseData(); const RigEclipseCaseData* caseData = settings.caseToApply()->eclipseCaseData();

View File

@ -1168,7 +1168,12 @@ std::vector<RigCompletionData> RicWellPathExportCompletionDataFeatureImpl::gener
RiaEclipseUnitTools::UnitSystem unitSystem = settings.caseToApply->eclipseCaseData()->unitsType(); RiaEclipseUnitTools::UnitSystem unitSystem = settings.caseToApply->eclipseCaseData()->unitsType();
std::vector<RigCompletionData> completionData; std::vector<RigCompletionData> completionData;
const RigActiveCellInfo* activeCellInfo = settings.caseToApply->eclipseCaseData()->activeCellInfo( if ( !wellPath || !wellPath->wellPathGeometry() )
{
return completionData;
}
const RigActiveCellInfo* activeCellInfo = settings.caseToApply->eclipseCaseData()->activeCellInfo(
RiaDefines::MATRIX_MODEL ); RiaDefines::MATRIX_MODEL );
if ( wellPath->perforationIntervalCollection()->isChecked() ) if ( wellPath->perforationIntervalCollection()->isChecked() )

View File

@ -254,7 +254,7 @@ QString RicWellPathFractureTextReportFeatureImpl::createWellFileLocationText( co
if ( fileWellPath ) if ( fileWellPath )
{ {
formatter.add( wellPath->name() ); formatter.add( wellPath->name() );
formatter.add( fileWellPath->filepath() ); formatter.add( fileWellPath->filePath() );
formatter.rowCompleted(); formatter.rowCompleted();
} }
} }

View File

@ -125,7 +125,7 @@ void RicSaveEclipseInputPropertyFeature::onActionTriggered( bool isChecked )
&errorMsg ); &errorMsg );
if ( isOk ) if ( isOk )
{ {
inputProperty->fileName = exportSettings.fileName; inputProperty->fileName = exportSettings.fileName();
inputProperty->eclipseKeyword = exportSettings.eclipseKeyword; inputProperty->eclipseKeyword = exportSettings.eclipseKeyword;
inputProperty->resolvedState = RimEclipseInputProperty::RESOLVED; inputProperty->resolvedState = RimEclipseInputProperty::RESOLVED;

View File

@ -21,9 +21,12 @@
#include "RiaApplication.h" #include "RiaApplication.h"
#include "RiaPreferences.h" #include "RiaPreferences.h"
#include "RimFileWellPath.h"
#include "RimProject.h" #include "RimProject.h"
#include "RimTools.h" #include "RimTools.h"
#include "RimWellPathImport.h" #include "RimWellPathImport.h"
#include "RiuMainWindow.h" #include "RiuMainWindow.h"
#include "RiuWellImportWizard.h" #include "RiuWellImportWizard.h"
@ -82,8 +85,7 @@ void RicWellPathsImportSsihubFeature::onActionTriggered( bool isChecked )
// Update the UTM bounding box from the reservoir // Update the UTM bounding box from the reservoir
app->project()->computeUtmAreaOfInterest(); app->project()->computeUtmAreaOfInterest();
QString wellPathsFolderPath = RimTools::getCacheRootDirectoryPathFromProject(); QString wellPathsFolderPath = RimFileWellPath::getCacheDirectoryPath();
wellPathsFolderPath += "_wellpaths";
QDir::root().mkpath( wellPathsFolderPath ); QDir::root().mkpath( wellPathsFolderPath );
if ( !app->project()->wellPathImport() ) return; if ( !app->project()->wellPathImport() ) return;

View File

@ -18,6 +18,7 @@
#include "RimWellPathImport.h" #include "RimWellPathImport.h"
#include "RimFileWellPath.h"
#include "RimOilFieldEntry.h" #include "RimOilFieldEntry.h"
#include "RimOilRegionEntry.h" #include "RimOilRegionEntry.h"
#include "RimTools.h" #include "RimTools.h"
@ -224,8 +225,7 @@ RimWellPathImport::~RimWellPathImport()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellPathImport::updateFilePaths() void RimWellPathImport::updateFilePaths()
{ {
QString wellPathsFolderPath = RimTools::getCacheRootDirectoryPathFromProject(); QString wellPathsFolderPath = RimFileWellPath::getCacheDirectoryPath();
wellPathsFolderPath += "_wellpaths";
for ( size_t regionIdx = 0; regionIdx < this->regions.size(); regionIdx++ ) for ( size_t regionIdx = 0; regionIdx < this->regions.size(); regionIdx++ )
{ {

View File

@ -323,6 +323,11 @@ message ExportContourMapToTextRequest
int32 viewId = 5; int32 viewId = 5;
} }
message SaveProjectRequest
{
string filePath = 1;
}
/* CommandParams handles both command name and parameters in one. /* CommandParams handles both command name and parameters in one.
* The message type and content is used as parameters and * The message type and content is used as parameters and
* the name of the variable is used to find the command name. */ * the name of the variable is used to find the command name. */
@ -372,6 +377,7 @@ message CommandParams
ExportWellLogPlotDataRequest exportWellLogPlotData = 36; ExportWellLogPlotDataRequest exportWellLogPlotData = 36;
SetWindowSizeParams setPlotWindowSize = 37; SetWindowSizeParams setPlotWindowSize = 37;
ExportContourMapToTextRequest exportContourMapToText = 38; ExportContourMapToTextRequest exportContourMapToText = 38;
SaveProjectRequest saveProject = 39;
} }
} }

View File

@ -36,6 +36,14 @@ class Project(PdmObject):
""" """
self._execute_command(openProject=Cmd.FilePathRequest(path=path)) self._execute_command(openProject=Cmd.FilePathRequest(path=path))
return self return self
def save(self, path=""):
"""Save the project to the existing project file, or to a new file
Arguments:
path(str): File path to the file to save the project to. If empty, saves to the active project file
"""
self._execute_command(saveProject=Cmd.SaveProjectRequest(filePath=path))
return self
def close(self): def close(self):
"""Close the current project (and open new blank project)""" """Close the current project (and open new blank project)"""

View File

@ -69,7 +69,7 @@ RimStimPlanFractureTemplate::RimStimPlanFractureTemplate()
CAF_PDM_InitObject("Fracture Template", ":/FractureTemplate16x16.png", "", ""); CAF_PDM_InitObject("Fracture Template", ":/FractureTemplate16x16.png", "", "");
CAF_PDM_InitField(&m_stimPlanFileName, "StimPlanFileName", QString(""), "File Name", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_stimPlanFileName, "StimPlanFileName", "File Name", "", "", "");
m_stimPlanFileName.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName()); m_stimPlanFileName.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
CAF_PDM_InitField(&m_wellPathDepthAtFracture, "WellPathDepthAtFracture", 0.0, "Well/Fracture Intersection Depth", "", "", ""); CAF_PDM_InitField(&m_wellPathDepthAtFracture, "WellPathDepthAtFracture", 0.0, "Well/Fracture Intersection Depth", "", "", "");
@ -171,9 +171,9 @@ void RimStimPlanFractureTemplate::setFileName( const QString& fileName )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
const QString& RimStimPlanFractureTemplate::fileName() QString RimStimPlanFractureTemplate::fileName()
{ {
return m_stimPlanFileName(); return m_stimPlanFileName().path();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -182,7 +182,7 @@ const QString& RimStimPlanFractureTemplate::fileName()
void RimStimPlanFractureTemplate::updateFilePathsFromProjectPath( const QString& newProjectPath, void RimStimPlanFractureTemplate::updateFilePathsFromProjectPath( const QString& newProjectPath,
const QString& oldProjectPath ) const QString& oldProjectPath )
{ {
m_stimPlanFileName = RimTools::relocateFile( m_stimPlanFileName(), newProjectPath, oldProjectPath, nullptr, nullptr ); // m_stimPlanFileName = RimTools::relocateFile( m_stimPlanFileName(), newProjectPath, oldProjectPath, nullptr, nullptr );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -253,7 +253,7 @@ void RimStimPlanFractureTemplate::loadDataAndUpdate()
if ( m_readError ) return; if ( m_readError ) return;
m_stimPlanFractureDefinitionData = RifStimPlanXmlReader::readStimPlanXMLFile( m_stimPlanFileName(), m_stimPlanFractureDefinitionData = RifStimPlanXmlReader::readStimPlanXMLFile( m_stimPlanFileName().path(),
m_conductivityScaleFactor(), m_conductivityScaleFactor(),
m_halfLengthScaleFactor(), m_halfLengthScaleFactor(),
m_heightScaleFactor(), m_heightScaleFactor(),

View File

@ -56,8 +56,8 @@ public:
void loadDataAndUpdate() override; void loadDataAndUpdate() override;
void setDefaultsBasedOnXMLfile(); void setDefaultsBasedOnXMLfile();
void setFileName( const QString& fileName ); void setFileName( const QString& fileName );
const QString& fileName(); QString fileName();
void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ); void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath );
@ -130,7 +130,7 @@ private:
caf::PdmField<double> m_wellPathDepthAtFracture; caf::PdmField<double> m_wellPathDepthAtFracture;
caf::PdmField<QString> m_borderPolygonResultName; caf::PdmField<QString> m_borderPolygonResultName;
caf::PdmField<QString> m_stimPlanFileName; caf::PdmField<caf::FilePath> m_stimPlanFileName;
cvf::ref<RigStimPlanFractureDefinition> m_stimPlanFractureDefinitionData; cvf::ref<RigStimPlanFractureDefinition> m_stimPlanFractureDefinitionData;
cvf::ref<RigFractureGrid> m_fractureGrid; cvf::ref<RigFractureGrid> m_fractureGrid;
bool m_readError; bool m_readError;

View File

@ -89,8 +89,8 @@ RimEclipseCase::RimEclipseCase()
CAF_PDM_InitField( &m_flipXAxis, "FlipXAxis", false, "Flip X Axis", "", "", "" ); CAF_PDM_InitField( &m_flipXAxis, "FlipXAxis", false, "Flip X Axis", "", "", "" );
CAF_PDM_InitField( &m_flipYAxis, "FlipYAxis", false, "Flip Y Axis", "", "", "" ); CAF_PDM_InitField( &m_flipYAxis, "FlipYAxis", false, "Flip Y Axis", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_filesContainingFaultsSemColSeparated, "CachedFileNamesContainingFaults", "", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_filesContainingFaults, "CachedFileNamesContainingFaults", "", "", "", "" );
m_filesContainingFaultsSemColSeparated.uiCapability()->setUiHidden( true ); m_filesContainingFaults.uiCapability()->setUiHidden( true );
CAF_PDM_InitFieldNoDefault( &m_contourMapCollection, "ContourMaps", "2d Contour Maps", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_contourMapCollection, "ContourMaps", "2d Contour Maps", "", "", "" );
m_contourMapCollection = new RimEclipseContourMapViewCollection; m_contourMapCollection = new RimEclipseContourMapViewCollection;
@ -746,12 +746,12 @@ const RimReservoirCellResultsStorage* RimEclipseCase::resultsStorage( RiaDefines
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::vector<QString> RimEclipseCase::filesContainingFaults() const std::vector<QString> RimEclipseCase::filesContainingFaults() const
{ {
QString separatedPaths = m_filesContainingFaultsSemColSeparated;
QStringList pathList = separatedPaths.split( ";", QString::SkipEmptyParts );
std::vector<QString> stdPathList; std::vector<QString> stdPathList;
for ( auto& path : pathList ) for ( auto& filePath : m_filesContainingFaults() )
stdPathList.push_back( path ); {
stdPathList.push_back( filePath.path() );
}
return stdPathList; return stdPathList;
} }
@ -759,20 +759,15 @@ std::vector<QString> RimEclipseCase::filesContainingFaults() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimEclipseCase::setFilesContainingFaults( const std::vector<QString>& val ) void RimEclipseCase::setFilesContainingFaults( const std::vector<QString>& pathStrings )
{ {
QString separatedPaths; std::vector<caf::FilePath> filePaths;
for ( const auto& pathString : pathStrings )
for ( size_t i = 0; i < val.size(); ++i )
{ {
const auto& path = val[i]; filePaths.push_back( pathString );
separatedPaths += path;
if ( !( i + 1 >= val.size() ) )
{
separatedPaths += ";";
}
} }
m_filesContainingFaultsSemColSeparated = separatedPaths;
m_filesContainingFaults = filePaths;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -145,8 +145,8 @@ protected:
caf::PdmChildField<RimEclipseInputPropertyCollection*> m_inputPropertyCollection; caf::PdmChildField<RimEclipseInputPropertyCollection*> m_inputPropertyCollection;
private: private:
caf::PdmField<QString> m_filesContainingFaultsSemColSeparated; caf::PdmField<std::vector<caf::FilePath>> m_filesContainingFaults;
caf::PdmField<bool> m_releaseResultMemory; caf::PdmField<bool> m_releaseResultMemory;
caf::PdmChildField<RimEclipseContourMapViewCollection*> m_contourMapCollection; caf::PdmChildField<RimEclipseContourMapViewCollection*> m_contourMapCollection;

View File

@ -55,7 +55,7 @@ RimEclipseInputCase::RimEclipseInputCase()
: RimEclipseCase() : RimEclipseCase()
{ {
CAF_PDM_InitObject( "RimInputCase", ":/EclipseInput48x48.png", "", "" ); CAF_PDM_InitObject( "RimInputCase", ":/EclipseInput48x48.png", "", "" );
CAF_PDM_InitField( &m_gridFileName, "GridFileName", QString(), "Case File Name", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_gridFileName, "GridFileName", "Case File Name", "", "", "" );
m_gridFileName.uiCapability()->setUiReadOnly( true ); m_gridFileName.uiCapability()->setUiReadOnly( true );
CAF_PDM_InitFieldNoDefault( &m_additionalFiles, "AdditionalFileNamesProxy", "Additional Files", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_additionalFiles, "AdditionalFileNamesProxy", "Additional Files", "", "", "" );
@ -190,16 +190,16 @@ bool RimEclipseInputCase::openEclipseGridFile()
{ {
cvf::ref<RifReaderInterface> readerInterface; cvf::ref<RifReaderInterface> readerInterface;
if ( m_gridFileName().contains( RiaDefines::mockModelBasicInputCase() ) ) if ( m_gridFileName().path().contains( RiaDefines::mockModelBasicInputCase() ) )
{ {
readerInterface = this->createMockModel( this->m_gridFileName() ); readerInterface = this->createMockModel( this->m_gridFileName().path() );
} }
else else
{ {
readerInterface = new RifReaderEclipseInput; readerInterface = new RifReaderEclipseInput;
cvf::ref<RigEclipseCaseData> eclipseCase = new RigEclipseCaseData( this ); cvf::ref<RigEclipseCaseData> eclipseCase = new RigEclipseCaseData( this );
if ( !readerInterface->open( m_gridFileName, eclipseCase.p() ) ) if ( !readerInterface->open( m_gridFileName().path(), eclipseCase.p() ) )
{ {
return false; return false;
} }
@ -258,7 +258,7 @@ void RimEclipseInputCase::loadAndSyncronizeInputProperties()
{ {
filenames.push_back( fileName ); filenames.push_back( fileName );
} }
filenames.push_back( m_gridFileName ); filenames.push_back( m_gridFileName().path() );
RifEclipseInputPropertyLoader::loadAndSyncronizeInputProperties( inputPropertyCollection(), RifEclipseInputPropertyLoader::loadAndSyncronizeInputProperties( inputPropertyCollection(),
eclipseCaseData(), eclipseCaseData(),
@ -302,7 +302,7 @@ cvf::ref<RifReaderInterface> RimEclipseInputCase::createMockModel( QString model
RimEclipseInputProperty* inputProperty = new RimEclipseInputProperty; RimEclipseInputProperty* inputProperty = new RimEclipseInputProperty;
inputProperty->resultName = "PORO"; inputProperty->resultName = "PORO";
inputProperty->eclipseKeyword = "PORO"; inputProperty->eclipseKeyword = "PORO";
inputProperty->fileName = "PORO.prop"; inputProperty->fileName = QString( "PORO.prop" );
m_inputPropertyCollection->inputProperties.push_back( inputProperty ); m_inputPropertyCollection->inputProperties.push_back( inputProperty );
} }
@ -332,9 +332,9 @@ void RimEclipseInputCase::defineUiOrdering( QString uiConfigName, caf::PdmUiOrde
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QString RimEclipseInputCase::locationOnDisc() const QString RimEclipseInputCase::locationOnDisc() const
{ {
if ( m_gridFileName().isEmpty() ) return QString(); if ( m_gridFileName().path().isEmpty() ) return QString();
QFileInfo fi( m_gridFileName ); QFileInfo fi( m_gridFileName().path() );
return fi.absolutePath(); return fi.absolutePath();
} }
@ -343,19 +343,19 @@ QString RimEclipseInputCase::locationOnDisc() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimEclipseInputCase::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) void RimEclipseInputCase::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath )
{ {
bool foundFile = false; // bool foundFile = false;
std::vector<QString> searchedPaths; // std::vector<QString> searchedPaths;
m_gridFileName = RimTools::relocateFile( m_gridFileName(), newProjectPath, oldProjectPath, &foundFile, &searchedPaths ); // m_gridFileName = RimTools::relocateFile( m_gridFileName().path(), newProjectPath, oldProjectPath, &foundFile, &searchedPaths );
for ( RimEclipseInputProperty* inputProperty : m_inputPropertyCollection()->inputProperties() ) // for ( RimEclipseInputProperty* inputProperty : m_inputPropertyCollection()->inputProperties() )
{ //{
inputProperty->fileName = RimTools::relocateFile( inputProperty->fileName, // inputProperty->fileName = RimTools::relocateFile( inputProperty->fileName,
newProjectPath, // newProjectPath,
oldProjectPath, // oldProjectPath,
&foundFile, // &foundFile,
&searchedPaths ); // &searchedPaths );
} //}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -366,8 +366,9 @@ void RimEclipseInputCase::updateAdditionalFileFolder( const QString& newFolder )
QDir newDir( newFolder ); QDir newDir( newFolder );
for ( RimEclipseInputProperty* inputProperty : m_inputPropertyCollection()->inputProperties() ) for ( RimEclipseInputProperty* inputProperty : m_inputPropertyCollection()->inputProperties() )
{ {
if ( inputProperty->fileName == m_gridFileName ) continue; if ( inputProperty->fileName == m_gridFileName().path() ) continue;
QFileInfo oldFilePath( inputProperty->fileName );
QFileInfo oldFilePath( inputProperty->fileName().path() );
QFileInfo newFilePath( newDir, oldFilePath.fileName() ); QFileInfo newFilePath( newDir, oldFilePath.fileName() );
inputProperty->fileName = newFilePath.absoluteFilePath(); inputProperty->fileName = newFilePath.absoluteFilePath();
} }
@ -381,8 +382,10 @@ std::vector<QString> RimEclipseInputCase::additionalFiles() const
std::vector<QString> additionalFiles; std::vector<QString> additionalFiles;
for ( const RimEclipseInputProperty* inputProperty : m_inputPropertyCollection()->inputProperties() ) for ( const RimEclipseInputProperty* inputProperty : m_inputPropertyCollection()->inputProperties() )
{ {
if ( inputProperty->fileName == m_gridFileName ) continue; if ( inputProperty->fileName == m_gridFileName().path() ) continue;
additionalFiles.push_back( inputProperty->fileName );
additionalFiles.push_back( inputProperty->fileName().path() );
} }
return additionalFiles; return additionalFiles;
} }

View File

@ -57,7 +57,7 @@ public:
QString locationOnDisc() const override; QString locationOnDisc() const override;
QString gridFileName() const override QString gridFileName() const override
{ {
return m_gridFileName(); return m_gridFileName().path();
} }
void updateFilePathsFromProjectPath( const QString& projectPath, const QString& oldProjectPath ) override; void updateFilePathsFromProjectPath( const QString& projectPath, const QString& oldProjectPath ) override;
@ -75,7 +75,7 @@ private:
private: private:
// Fields // Fields
caf::PdmField<QString> m_gridFileName; caf::PdmField<caf::FilePath> m_gridFileName;
caf::PdmProxyValueField<std::vector<QString>> m_additionalFiles; caf::PdmProxyValueField<std::vector<QString>> m_additionalFiles;
// Obsolete fields // Obsolete fields

View File

@ -58,7 +58,7 @@ RimEclipseInputProperty::RimEclipseInputProperty()
CAF_PDM_InitField( &resultName, "ResultName", QString(), "Result Name", "", "", "" ); CAF_PDM_InitField( &resultName, "ResultName", QString(), "Result Name", "", "", "" );
CAF_PDM_InitField( &eclipseKeyword, "EclipseKeyword", QString(), "Eclipse Keyword", "", "", "" ); CAF_PDM_InitField( &eclipseKeyword, "EclipseKeyword", QString(), "Eclipse Keyword", "", "", "" );
CAF_PDM_InitField( &fileName, "FileName", QString(), "Filename", "", "", "" ); CAF_PDM_InitFieldNoDefault( &fileName, "FileName", "Filename", "", "", "" );
CAF_PDM_InitField( &resolvedState, "ResolvedState", (ResolveStateEnum)UNKNOWN, "Data State", "", "", "" ); CAF_PDM_InitField( &resolvedState, "ResolvedState", (ResolveStateEnum)UNKNOWN, "Data State", "", "", "" );
resolvedState.uiCapability()->setUiReadOnly( true ); resolvedState.uiCapability()->setUiReadOnly( true );

View File

@ -49,9 +49,10 @@ public:
typedef caf::AppEnum<ResolveState> ResolveStateEnum; typedef caf::AppEnum<ResolveState> ResolveStateEnum;
// Fields: // Fields:
caf::PdmField<QString> resultName; caf::PdmField<QString> resultName;
caf::PdmField<QString> eclipseKeyword; caf::PdmField<QString> eclipseKeyword;
caf::PdmField<QString> fileName; // ReadOnly Serves as key to syncronize read eclipse prop data and this inputProp object. caf::PdmField<caf::FilePath> fileName; // ReadOnly Serves as key to syncronize
// read eclipse prop data and this inputProp object.
caf::PdmField<ResolveStateEnum> resolvedState; // ReadOnly and not writable caf::PdmField<ResolveStateEnum> resolvedState; // ReadOnly and not writable
// PdmObject Overrides // PdmObject Overrides

View File

@ -56,7 +56,7 @@ std::vector<RimEclipseInputProperty*> RimEclipseInputPropertyCollection::findInp
{ {
if ( !inputProperties[i] ) continue; if ( !inputProperties[i] ) continue;
QFileInfo propFile( inputProperties[i]->fileName() ); QFileInfo propFile( inputProperties[i]->fileName().path() );
if ( fileInfo == propFile ) result.push_back( inputProperties[i] ); if ( fileInfo == propFile ) result.push_back( inputProperties[i] );
} }

View File

@ -72,7 +72,7 @@ RimEclipseResultCase::RimEclipseResultCase()
{ {
CAF_PDM_InitObject( "Eclipse Case", ":/Case48x48.png", "", "" ); CAF_PDM_InitObject( "Eclipse Case", ":/Case48x48.png", "", "" );
RICF_InitField( &caseFileName, "CaseFileName", QString(), "Case File Name", "", "", "" ); RICF_InitFieldNoDefault( &caseFileName, "CaseFileName", "Case File Name", "", "", "" );
caseFileName.uiCapability()->setUiReadOnly( true ); caseFileName.uiCapability()->setUiReadOnly( true );
caseFileName.capability<RicfFieldHandle>()->setIOWriteable( false ); caseFileName.capability<RicfFieldHandle>()->setIOWriteable( false );
@ -94,7 +94,7 @@ RimEclipseResultCase::RimEclipseResultCase()
m_flipYAxis.xmlCapability()->setIOWritable( true ); m_flipYAxis.xmlCapability()->setIOWritable( true );
// flipYAxis.uiCapability()->setUiHidden(true); // flipYAxis.uiCapability()->setUiHidden(true);
CAF_PDM_InitField( &m_sourSimFileName, "SourSimFileName", QString(), "SourSim File Name", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_sourSimFileName, "SourSimFileName", "SourSim File Name", "", "", "" );
m_sourSimFileName.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); m_sourSimFileName.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() );
#ifndef USE_HDF5 #ifndef USE_HDF5
m_sourSimFileName.uiCapability()->setUiHidden( true ); m_sourSimFileName.uiCapability()->setUiHidden( true );
@ -127,13 +127,13 @@ bool RimEclipseResultCase::importGridAndResultMetaData( bool showTimeStepFilter
cvf::ref<RifReaderInterface> readerInterface; cvf::ref<RifReaderInterface> readerInterface;
if ( caseFileName().contains( "Result Mock Debug Model" ) ) if ( caseFileName().path().contains( "Result Mock Debug Model" ) )
{ {
readerInterface = this->createMockModel( this->caseFileName() ); readerInterface = this->createMockModel( this->caseFileName().path() );
} }
else else
{ {
if ( !caf::Utils::fileExists( caseFileName() ) ) if ( !caf::Utils::fileExists( caseFileName().path() ) )
{ {
return false; return false;
} }
@ -142,7 +142,7 @@ bool RimEclipseResultCase::importGridAndResultMetaData( bool showTimeStepFilter
readerEclipseOutput->setFilenamesWithFaults( this->filesContainingFaults() ); readerEclipseOutput->setFilenamesWithFaults( this->filesContainingFaults() );
cvf::ref<RifEclipseRestartDataAccess> restartDataAccess = RifEclipseOutputFileTools::createDynamicResultAccess( cvf::ref<RifEclipseRestartDataAccess> restartDataAccess = RifEclipseOutputFileTools::createDynamicResultAccess(
caseFileName() ); caseFileName().path() );
{ {
std::vector<QDateTime> timeSteps; std::vector<QDateTime> timeSteps;
@ -177,11 +177,12 @@ bool RimEclipseResultCase::importGridAndResultMetaData( bool showTimeStepFilter
} }
m_timeStepFilter->updateFilteredTimeStepsFromUi(); m_timeStepFilter->updateFilteredTimeStepsFromUi();
} }
readerEclipseOutput->setFileDataAccess( restartDataAccess.p() ); readerEclipseOutput->setFileDataAccess( restartDataAccess.p() );
readerEclipseOutput->setTimeStepFilter( m_timeStepFilter->filteredTimeSteps() ); readerEclipseOutput->setTimeStepFilter( m_timeStepFilter->filteredTimeSteps() );
cvf::ref<RigEclipseCaseData> eclipseCase = new RigEclipseCaseData( this ); cvf::ref<RigEclipseCaseData> eclipseCase = new RigEclipseCaseData( this );
if ( !readerEclipseOutput->open( caseFileName(), eclipseCase.p() ) ) if ( !readerEclipseOutput->open( caseFileName().path(), eclipseCase.p() ) )
{ {
return false; return false;
} }
@ -209,7 +210,7 @@ bool RimEclipseResultCase::importGridAndResultMetaData( bool showTimeStepFilter
m_gridAndWellDataIsReadFromFile = true; m_gridAndWellDataIsReadFromFile = true;
m_activeCellInfoIsReadFromFile = true; m_activeCellInfoIsReadFromFile = true;
QFileInfo eclipseCaseFileInfo( caseFileName() ); QFileInfo eclipseCaseFileInfo( caseFileName().path() );
QString rftFileName = eclipseCaseFileInfo.path() + "/" + eclipseCaseFileInfo.completeBaseName() + ".RFT"; QString rftFileName = eclipseCaseFileInfo.path() + "/" + eclipseCaseFileInfo.completeBaseName() + ".RFT";
QFileInfo rftFileInfo( rftFileName ); QFileInfo rftFileInfo( rftFileName );
@ -224,10 +225,10 @@ bool RimEclipseResultCase::importGridAndResultMetaData( bool showTimeStepFilter
m_flowDiagSolutions.push_back( new RimFlowDiagSolution() ); m_flowDiagSolutions.push_back( new RimFlowDiagSolution() );
} }
if ( !m_sourSimFileName().isEmpty() ) if ( !m_sourSimFileName().path().isEmpty() )
{ {
RifReaderEclipseOutput* outReader = dynamic_cast<RifReaderEclipseOutput*>( readerInterface.p() ); RifReaderEclipseOutput* outReader = dynamic_cast<RifReaderEclipseOutput*>( readerInterface.p() );
outReader->setHdf5FileName( m_sourSimFileName() ); outReader->setHdf5FileName( m_sourSimFileName().path() );
} }
RiaApplication* app = RiaApplication::instance(); RiaApplication* app = RiaApplication::instance();
@ -274,13 +275,13 @@ bool RimEclipseResultCase::openAndReadActiveCellData( RigEclipseCaseData* mainEc
if ( m_activeCellInfoIsReadFromFile ) return true; if ( m_activeCellInfoIsReadFromFile ) return true;
cvf::ref<RifReaderInterface> readerInterface; cvf::ref<RifReaderInterface> readerInterface;
if ( caseFileName().contains( "Result Mock Debug Model" ) ) if ( caseFileName().path().contains( "Result Mock Debug Model" ) )
{ {
readerInterface = this->createMockModel( this->caseFileName() ); readerInterface = this->createMockModel( this->caseFileName().path() );
} }
else else
{ {
if ( !caf::Utils::fileExists( caseFileName() ) ) if ( !caf::Utils::fileExists( caseFileName().path() ) )
{ {
return false; return false;
} }
@ -292,7 +293,7 @@ bool RimEclipseResultCase::openAndReadActiveCellData( RigEclipseCaseData* mainEc
std::vector<QDateTime> timeStepDates = mainEclipseCase->results( RiaDefines::MATRIX_MODEL )->timeStepDates(); std::vector<QDateTime> timeStepDates = mainEclipseCase->results( RiaDefines::MATRIX_MODEL )->timeStepDates();
cvf::ref<RifReaderEclipseOutput> readerEclipseOutput = new RifReaderEclipseOutput; cvf::ref<RifReaderEclipseOutput> readerEclipseOutput = new RifReaderEclipseOutput;
if ( !readerEclipseOutput->openAndReadActiveCellData( caseFileName(), timeStepDates, eclipseCase.p() ) ) if ( !readerEclipseOutput->openAndReadActiveCellData( caseFileName().path(), timeStepDates, eclipseCase.p() ) )
{ {
return false; return false;
} }
@ -322,7 +323,7 @@ void RimEclipseResultCase::loadAndUpdateSourSimData()
{ {
if ( !results( RiaDefines::MATRIX_MODEL ) ) return; if ( !results( RiaDefines::MATRIX_MODEL ) ) return;
results( RiaDefines::MATRIX_MODEL )->setHdf5Filename( m_sourSimFileName ); results( RiaDefines::MATRIX_MODEL )->setHdf5Filename( m_sourSimFileName().path() );
if ( !hasSourSimFile() ) if ( !hasSourSimFile() )
{ {
@ -468,7 +469,7 @@ RimEclipseResultCase::~RimEclipseResultCase()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QString RimEclipseResultCase::locationOnDisc() const QString RimEclipseResultCase::locationOnDisc() const
{ {
QFileInfo fi( caseFileName() ); QFileInfo fi( caseFileName().path() );
return fi.absolutePath(); return fi.absolutePath();
} }
@ -477,7 +478,7 @@ QString RimEclipseResultCase::locationOnDisc() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimEclipseResultCase::readGridDimensions( std::vector<std::vector<int>>& gridDimensions ) void RimEclipseResultCase::readGridDimensions( std::vector<std::vector<int>>& gridDimensions )
{ {
RifEclipseOutputFileTools::readGridDimensions( caseFileName(), gridDimensions ); RifEclipseOutputFileTools::readGridDimensions( caseFileName().path(), gridDimensions );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -485,22 +486,22 @@ void RimEclipseResultCase::readGridDimensions( std::vector<std::vector<int>>& gr
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimEclipseResultCase::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) void RimEclipseResultCase::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath )
{ {
bool foundFile = false; // bool foundFile = false;
std::vector<QString> searchedPaths; // std::vector<QString> searchedPaths;
// Update filename and folder paths when opening project from a different file location // Update filename and folder paths when opening project from a different file location
caseFileName = RimTools::relocateFile( caseFileName(), newProjectPath, oldProjectPath, &foundFile, &searchedPaths ); // caseFileName = RimTools::relocateFile( caseFileName().path(), newProjectPath, oldProjectPath, &foundFile, &searchedPaths );
std::vector<QString> relocatedFaultFiles; // std::vector<QString> relocatedFaultFiles;
const std::vector<QString>& orgFilesContainingFaults = filesContainingFaults(); // const std::vector<QString>& orgFilesContainingFaults = filesContainingFaults();
for ( auto faultFileName : orgFilesContainingFaults ) // for ( auto faultFileName : orgFilesContainingFaults )
{ // {
QString relocatedFaultFile = // QString relocatedFaultFile =
RimTools::relocateFile( faultFileName, newProjectPath, oldProjectPath, &foundFile, &searchedPaths ); // RimTools::relocateFile( faultFileName, newProjectPath, oldProjectPath, &foundFile, &searchedPaths );
relocatedFaultFiles.push_back( relocatedFaultFile ); // relocatedFaultFiles.push_back( relocatedFaultFile );
} // }
//
setFilesContainingFaults( relocatedFaultFiles ); // setFilesContainingFaults( relocatedFaultFiles );
#if 0 // Output the search path for debugging #if 0 // Output the search path for debugging
for (size_t i = 0; i < searchedPaths.size(); ++i) for (size_t i = 0; i < searchedPaths.size(); ++i)
@ -586,7 +587,7 @@ void RimEclipseResultCase::setSourSimFileName( const QString& fileName )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RimEclipseResultCase::hasSourSimFile() bool RimEclipseResultCase::hasSourSimFile()
{ {
return !m_sourSimFileName().isEmpty(); return !m_sourSimFileName().path().isEmpty();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -597,7 +598,7 @@ void RimEclipseResultCase::initAfterRead()
RimEclipseCase::initAfterRead(); RimEclipseCase::initAfterRead();
// Convert from old (9.0.2) way of storing the case file // Convert from old (9.0.2) way of storing the case file
if ( caseFileName().isEmpty() ) if ( caseFileName().path().isEmpty() )
{ {
if ( !this->m_caseName_OBSOLETE().isEmpty() && !caseDirectory().isEmpty() ) if ( !this->m_caseName_OBSOLETE().isEmpty() && !caseDirectory().isEmpty() )
{ {
@ -658,7 +659,7 @@ void RimEclipseResultCase::defineEditorAttribute( const caf::PdmFieldHandle* fie
if ( myAttr ) if ( myAttr )
{ {
myAttr->m_fileSelectionFilter = "SourSim (*.sourres)"; myAttr->m_fileSelectionFilter = "SourSim (*.sourres)";
myAttr->m_defaultPath = QFileInfo( caseFileName() ).absolutePath(); myAttr->m_defaultPath = QFileInfo( caseFileName().path() ).absolutePath();
} }
} }
} }

View File

@ -24,6 +24,7 @@
#include "RimEclipseCase.h" #include "RimEclipseCase.h"
#include "cafFilePath.h"
#include <cafPdmProxyValueField.h> #include <cafPdmProxyValueField.h>
class RifReaderEclipseRft; class RifReaderEclipseRft;
@ -65,7 +66,7 @@ public:
QString locationOnDisc() const override; QString locationOnDisc() const override;
QString gridFileName() const override QString gridFileName() const override
{ {
return caseFileName(); return caseFileName().path();
} }
void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) override; void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) override;
@ -98,10 +99,10 @@ private:
cvf::ref<RifReaderEclipseRft> m_readerEclipseRft; cvf::ref<RifReaderEclipseRft> m_readerEclipseRft;
// Fields: // Fields:
caf::PdmField<QString> caseFileName; caf::PdmField<caf::FilePath> caseFileName;
caf::PdmProxyValueField<RiaEclipseUnitTools::UnitSystemType> m_unitSystem; caf::PdmProxyValueField<RiaEclipseUnitTools::UnitSystemType> m_unitSystem;
caf::PdmChildArrayField<RimFlowDiagSolution*> m_flowDiagSolutions; caf::PdmChildArrayField<RimFlowDiagSolution*> m_flowDiagSolutions;
caf::PdmField<QString> m_sourSimFileName; caf::PdmField<caf::FilePath> m_sourSimFileName;
// Obsolete field // Obsolete field
caf::PdmField<QString> caseDirectory; caf::PdmField<QString> caseDirectory;

View File

@ -33,8 +33,11 @@ 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_InitFieldNoDefault( &m_filePathInCache, "WellPathFilePathInCache", "File Name", "", "", "" );
m_filePathInCache.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 );
} }
@ -47,9 +50,16 @@ RimFileWellPath::~RimFileWellPath() {}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QString RimFileWellPath::filepath() const QString RimFileWellPath::filePath() const
{ {
return m_filepath(); if ( isStoredInCache() || m_filePath().path().isEmpty() )
{
return m_filePathInCache();
}
else
{
return m_filePath().path();
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -57,7 +67,7 @@ QString RimFileWellPath::filepath() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimFileWellPath::setFilepath( const QString& path ) void RimFileWellPath::setFilepath( const QString& path )
{ {
m_filepath = path; m_filePath = path;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -96,7 +106,16 @@ void RimFileWellPath::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering
RimWellPath::defineUiOrdering( uiConfigName, uiOrdering ); RimWellPath::defineUiOrdering( uiConfigName, uiOrdering );
caf::PdmUiGroup* fileInfoGroup = uiOrdering.createGroupBeforeGroup( "Simulation Well", "File" ); caf::PdmUiGroup* fileInfoGroup = uiOrdering.createGroupBeforeGroup( "Simulation Well", "File" );
fileInfoGroup->add( &m_filepath );
if ( isStoredInCache() )
{
fileInfoGroup->add( &m_filePathInCache );
}
else
{
fileInfoGroup->add( &m_filePath );
}
fileInfoGroup->add( &m_wellPathIndexInFile ); fileInfoGroup->add( &m_wellPathIndexInFile );
if ( !id().isEmpty() ) uiOrdering.insertBeforeItem( m_datumElevation.uiCapability(), &id ); if ( !id().isEmpty() ) uiOrdering.insertBeforeItem( m_datumElevation.uiCapability(), &id );
@ -112,10 +131,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( this->filePath() ) )
{ {
RifWellPathImporter::WellData wellData = wellPathImporter->readWellData( m_filepath(), m_wellPathIndexInFile() ); RifWellPathImporter::WellData wellData = wellPathImporter->readWellData( this->filePath(),
RifWellPathImporter::WellMetaData wellMetaData = wellPathImporter->readWellMetaData( m_filepath(), m_wellPathIndexInFile() );
RifWellPathImporter::WellMetaData wellMetaData = wellPathImporter->readWellMetaData( this->filePath(),
m_wellPathIndexInFile() ); m_wellPathIndexInFile() );
// General well info // General well info
@ -128,11 +149,22 @@ bool RimFileWellPath::readWellPathFile( QString* errorMessage, RifWellPathImport
updateDate = wellMetaData.m_updateDate.toString( "d MMMM yyyy" ); updateDate = wellMetaData.m_updateDate.toString( "d MMMM yyyy" );
setWellPathGeometry( wellData.m_wellPathGeometry.p() ); 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; return true;
} }
else else
{ {
if ( errorMessage ) ( *errorMessage ) = "Could not find the well path file: " + m_filepath(); if ( errorMessage ) ( *errorMessage ) = "Could not find the well path file: " + this->filePath();
return false; return false;
} }
} }
@ -152,7 +184,7 @@ QString RimFileWellPath::getCacheDirectoryPath()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QString RimFileWellPath::getCacheFileName() QString RimFileWellPath::getCacheFileName()
{ {
if ( m_filepath().isEmpty() ) if ( m_filePathInCache().isEmpty() )
{ {
return ""; return "";
} }
@ -160,8 +192,9 @@ QString RimFileWellPath::getCacheFileName()
QString cacheFileName; QString cacheFileName;
// 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_filePathInCache() );
cacheFileName = newCacheDirPath + "/" + oldCacheFile.fileName(); cacheFileName = newCacheDirPath + "/" + oldCacheFile.fileName();
@ -173,13 +206,14 @@ QString RimFileWellPath::getCacheFileName()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimFileWellPath::setupBeforeSave() 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 // 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() ) if ( !isStoredInCache() )
{ {
return; return;
} }
if ( m_filepath().isEmpty() ) if ( m_filePathInCache().isEmpty() )
{ {
return; return;
} }
@ -189,21 +223,21 @@ 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_filePathInCache() );
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_filePathInCache(), newCacheFileName );
m_filepath = newCacheFileName; m_filePathInCache = newCacheFileName;
} }
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RimFileWellPath::isStoredInCache() 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 // 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(); return !id().isEmpty();
@ -214,7 +248,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() )
{ {
@ -222,11 +256,11 @@ void RimFileWellPath::updateFilePathsFromProjectPath( const QString& newProjectP
if ( caf::Utils::fileExists( newCacheFileName ) ) if ( caf::Utils::fileExists( newCacheFileName ) )
{ {
m_filepath = newCacheFileName; m_filePathInCache = 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

@ -26,12 +26,13 @@ public:
RimFileWellPath(); RimFileWellPath();
~RimFileWellPath() override; ~RimFileWellPath() override;
QString filepath() const; QString filePath() const;
void setFilepath( const QString& path ); void setFilepath( const QString& path );
bool readWellPathFile( QString* errorMessage, RifWellPathImporter* wellPathImporter ); bool readWellPathFile( QString* errorMessage, RifWellPathImporter* wellPathImporter );
int wellPathIndexInFile() const; // -1 means none. int wellPathIndexInFile() const; // -1 means none.
void setWellPathIndexInFile( int index ); void setWellPathIndexInFile( int index );
void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) override; void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) override;
static QString getCacheDirectoryPath();
private: private:
QString surveyType() QString surveyType()
@ -39,14 +40,14 @@ private:
return m_surveyType; return m_surveyType;
} }
void setSurveyType( QString surveyType ); void setSurveyType( QString surveyType );
bool isStoredInCache(); bool isStoredInCache() const;
QString getCacheFileName(); QString getCacheFileName();
QString getCacheDirectoryPath();
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<QString> m_filePathInCache; // Used for SSIHUB imported well paths
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

@ -42,7 +42,7 @@ RimFormationNames::RimFormationNames()
{ {
CAF_PDM_InitObject( "Formation Names", ":/Formations16x16.png", "", "" ); CAF_PDM_InitObject( "Formation Names", ":/Formations16x16.png", "", "" );
CAF_PDM_InitField( &m_formationNamesFileName, "FormationNamesFileName", QString( "" ), "File Name", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_formationNamesFileName, "FormationNamesFileName", "File Name", "", "", "" );
m_formationNamesFileName.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); m_formationNamesFileName.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() );
} }
@ -68,13 +68,14 @@ void RimFormationNames::fieldChangedByUi( const caf::PdmFieldHandle* changedFiel
{ {
QMessageBox::warning( nullptr, "Formation Names", errorMessage ); QMessageBox::warning( nullptr, "Formation Names", errorMessage );
} }
updateConnectedViews();
} }
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimFormationNames::initAfterRead() void RimFormationNames::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/ )
{ {
updateUiTreeName(); updateUiTreeName();
} }
@ -92,9 +93,9 @@ void RimFormationNames::setFileName( const QString& fileName )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
const QString& RimFormationNames::fileName() QString RimFormationNames::fileName()
{ {
return m_formationNamesFileName(); return m_formationNamesFileName().path();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -102,7 +103,7 @@ const QString& RimFormationNames::fileName()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QString RimFormationNames::fileNameWoPath() QString RimFormationNames::fileNameWoPath()
{ {
QFileInfo fnameFileInfo( m_formationNamesFileName() ); QFileInfo fnameFileInfo( m_formationNamesFileName().path() );
return fnameFileInfo.fileName(); return fnameFileInfo.fileName();
} }
@ -142,18 +143,19 @@ void RimFormationNames::updateConnectedViews()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimFormationNames::readFormationNamesFile( QString* errorMessage ) void RimFormationNames::readFormationNamesFile( QString* errorMessage )
{ {
QFile dataFile( m_formationNamesFileName() ); QFile dataFile( m_formationNamesFileName().path() );
if ( !dataFile.open( QFile::ReadOnly ) ) if ( !dataFile.open( QFile::ReadOnly ) )
{ {
if ( errorMessage ) ( *errorMessage ) += "Could not open the File: " + ( m_formationNamesFileName() ) + "\n"; if ( errorMessage )
( *errorMessage ) += "Could not open the File: " + ( m_formationNamesFileName().path() ) + "\n";
return; return;
} }
m_formationNamesData = new RigFormationNames; m_formationNamesData = new RigFormationNames;
QTextStream stream( &dataFile ); QTextStream stream( &dataFile );
QFileInfo fileInfo( m_formationNamesFileName() ); QFileInfo fileInfo( m_formationNamesFileName().path() );
if ( fileInfo.fileName() == RimFormationNames::layerZoneTableFileName() ) if ( fileInfo.fileName() == RimFormationNames::layerZoneTableFileName() )
{ {
@ -170,8 +172,8 @@ void RimFormationNames::readFormationNamesFile( QString* errorMessage )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimFormationNames::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) void RimFormationNames::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath )
{ {
m_formationNamesFileName = // m_formationNamesFileName =
RimTools::relocateFile( m_formationNamesFileName(), newProjectPath, oldProjectPath, nullptr, nullptr ); // RimTools::relocateFile( m_formationNamesFileName(), newProjectPath, oldProjectPath, nullptr, nullptr );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -297,8 +299,9 @@ void RimFormationNames::readFmuFormationNameFile( QTextStream& stream, QString*
if ( lineStream.status() != QTextStream::Ok ) if ( lineStream.status() != QTextStream::Ok )
{ {
*errorMessage = *errorMessage = QString( "Failed to parse line %1 of '%2'" )
QString( "Failed to parse line %1 of '%2'" ).arg( lineNumber ).arg( m_formationNamesFileName() ); .arg( lineNumber )
.arg( m_formationNamesFileName().path() );
return; return;
} }

View File

@ -36,9 +36,9 @@ public:
RimFormationNames(); RimFormationNames();
~RimFormationNames() override; ~RimFormationNames() override;
void setFileName( const QString& fileName ); void setFileName( const QString& fileName );
const QString& fileName(); QString fileName();
QString fileNameWoPath(); QString fileNameWoPath();
RigFormationNames* formationNamesData() RigFormationNames* formationNamesData()
{ {
@ -55,7 +55,8 @@ protected:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, void fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue, const QVariant& oldValue,
const QVariant& newValue ) override; const QVariant& newValue ) override;
void initAfterRead() override;
virtual void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
private: private:
void updateUiTreeName(); void updateUiTreeName();
@ -63,7 +64,7 @@ private:
void readFmuFormationNameFile( QTextStream& stream, QString* errorMessage ); void readFmuFormationNameFile( QTextStream& stream, QString* errorMessage );
private: private:
caf::PdmField<QString> m_formationNamesFileName; caf::PdmField<caf::FilePath> m_formationNamesFileName;
cvf::ref<RigFormationNames> m_formationNamesData; cvf::ref<RigFormationNames> m_formationNamesData;
}; };

View File

@ -97,6 +97,7 @@
#include <QDebug> #include <QDebug>
#include <QDir> #include <QDir>
#include <QMenu> #include <QMenu>
#include <algorithm>
CAF_PDM_SOURCE_INIT( RimProject, "ResInsightProject" ); CAF_PDM_SOURCE_INIT( RimProject, "ResInsightProject" );
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -114,6 +115,9 @@ RimProject::RimProject( void )
CAF_PDM_InitFieldNoDefault( &m_projectFileVersionString, "ProjectFileVersionString", "", "", "", "" ); CAF_PDM_InitFieldNoDefault( &m_projectFileVersionString, "ProjectFileVersionString", "", "", "", "" );
m_projectFileVersionString.uiCapability()->setUiHidden( true ); m_projectFileVersionString.uiCapability()->setUiHidden( true );
CAF_PDM_InitFieldNoDefault( &m_globalPathList, "ReferencedExternalFiles", "", "", "", "" );
m_globalPathList.uiCapability()->setUiHidden( true );
CAF_PDM_InitFieldNoDefault( &oilFields, "OilFields", "Oil Fields", "", "", "" ); CAF_PDM_InitFieldNoDefault( &oilFields, "OilFields", "Oil Fields", "", "", "" );
oilFields.uiCapability()->setUiHidden( true ); oilFields.uiCapability()->setUiHidden( true );
@ -257,6 +261,8 @@ void RimProject::close()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimProject::initAfterRead() void RimProject::initAfterRead()
{ {
this->distributePathsFromGlobalPathList();
// Create an empty oil field in case the project did not contain one // Create an empty oil field in case the project did not contain one
if ( oilFields.size() < 1 ) if ( oilFields.size() < 1 )
{ {
@ -332,6 +338,18 @@ void RimProject::setupBeforeSave()
m_projectFileVersionString = STRPRODUCTVER; m_projectFileVersionString = STRPRODUCTVER;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimProject::writeProjectFile()
{
this->transferPathsToGlobalPathList();
bool couldOpenFile = this->writeFile();
this->distributePathsFromGlobalPathList();
return couldOpenFile;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// Support list of multiple script paths divided by ';' /// Support list of multiple script paths divided by ';'
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -1368,3 +1386,203 @@ void RimProject::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, Q
uiTreeOrdering.skipRemainingChildren( true ); uiTreeOrdering.skipRemainingChildren( true );
} }
#define PATHIDCHAR "$"
class GlobalPathListMapper
{
const QString pathIdBaseString = "PathId_";
public:
GlobalPathListMapper( const QString& globalPathListTable )
{
m_nextValidIdNumber = 1;
QStringList pathPairs = globalPathListTable.split( ";", QString::SkipEmptyParts );
for ( const QString& pathIdPathPair : pathPairs )
{
QStringList pathIdPathComponents = pathIdPathPair.trimmed().split( PATHIDCHAR );
if ( pathIdPathComponents.size() == 3 && pathIdPathComponents[0].size() == 0 )
{
QString pathIdCore = pathIdPathComponents[1];
QString pathId = PATHIDCHAR + pathIdCore + PATHIDCHAR;
QString path = pathIdPathComponents[2].trimmed();
// Check if we have a standard id, and store the max number
if ( pathIdCore.startsWith( pathIdBaseString ) )
{
bool isOk = false;
QString numberText = pathIdCore.right( pathIdCore.size() - pathIdBaseString.size() );
size_t idNumber = numberText.toUInt( &isOk );
if ( isOk )
{
m_nextValidIdNumber = std::max( m_nextValidIdNumber, idNumber );
}
}
// Check for unique pathId
{
auto pathIdPathPairIt = m_oldPathIdToPathMap.find( pathId );
if ( pathIdPathPairIt != m_oldPathIdToPathMap.end() )
{
// Error: pathID is already used
}
}
// Check for multiple identical paths
{
auto pathPathIdPairIt = m_oldPathToPathIdMap.find( path );
if ( pathPathIdPairIt != m_oldPathToPathIdMap.end() )
{
// Warning: path has already been assigned a pathId
}
}
m_oldPathIdToPathMap[pathId] = path;
m_oldPathToPathIdMap[path] = pathId;
}
else
{
// Error: The text is ill formatted
}
}
}
QString addPathAndGetId( const QString& path )
{
// Want to re-use ids from last save to avoid unnecessary changes and make the behavior predictable
QString pathId;
QString trimmedPath = path.trimmed();
auto pathToIdIt = m_oldPathToPathIdMap.find( trimmedPath );
if ( pathToIdIt != m_oldPathToPathIdMap.end() )
{
pathId = pathToIdIt->second;
}
else
{
auto pathPathIdPairIt = m_newPathToPathIdMap.find( trimmedPath );
if ( pathPathIdPairIt != m_newPathToPathIdMap.end() )
{
pathId = pathPathIdPairIt->second;
}
else
{
pathId = createUnusedId();
}
}
m_newPathIdToPathMap[pathId] = trimmedPath;
m_newPathToPathIdMap[trimmedPath] = pathId;
return pathId;
};
QString newGlobalPathListTable() const
{
QString pathList;
pathList += "\n";
for ( const auto& pathIdPathPairIt : m_newPathIdToPathMap )
{
pathList += " " + pathIdPathPairIt.first + " " + pathIdPathPairIt.second + ";\n";
}
pathList += " ";
return pathList;
}
QString pathFromPathId( const QString& pathId, bool* isFound ) const
{
auto it = m_oldPathIdToPathMap.find( pathId );
if ( it != m_oldPathIdToPathMap.end() )
{
( *isFound ) = true;
return it->second;
}
( *isFound ) = false;
return "";
}
private:
QString createUnusedId()
{
QString numberString = QString( "%1" ).arg( (uint)m_nextValidIdNumber, 3, 10, QChar( '0' ) );
QString pathIdentifier = PATHIDCHAR + pathIdBaseString + numberString + PATHIDCHAR;
m_nextValidIdNumber++;
return pathIdentifier;
}
size_t m_nextValidIdNumber; // Set when parsing the globalPathListTable. Increment while creating new id's
std::map<QString, QString> m_newPathIdToPathMap;
std::map<QString, QString> m_newPathToPathIdMap;
std::map<QString, QString> m_oldPathIdToPathMap;
std::map<QString, QString> m_oldPathToPathIdMap;
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimProject::transferPathsToGlobalPathList()
{
GlobalPathListMapper pathListMapper( m_globalPathList() );
std::vector<caf::FilePath*> filePaths;
fieldContentsByType( this, filePaths );
for ( caf::FilePath* filePath : filePaths )
{
QString path = filePath->path();
if ( !path.isEmpty() )
{
QString pathId = pathListMapper.addPathAndGetId( path );
filePath->setPath( pathId );
}
}
m_globalPathList = pathListMapper.newGlobalPathListTable();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimProject::distributePathsFromGlobalPathList()
{
GlobalPathListMapper pathListMapper( m_globalPathList() );
std::vector<caf::FilePath*> filePaths;
fieldContentsByType( this, filePaths );
for ( caf::FilePath* filePath : filePaths )
{
QString pathIdCandidate = filePath->path().trimmed();
QStringList pathIdComponents = pathIdCandidate.split( PATHIDCHAR );
if ( pathIdComponents.size() == 3 && pathIdComponents[0].size() == 0 && pathIdComponents[1].size() > 0 &&
pathIdComponents[2].size() == 0 )
{
bool isFound = false;
QString path = pathListMapper.pathFromPathId( pathIdCandidate, &isFound );
if ( isFound )
{
filePath->setPath( path );
}
else
{
// The pathId can not be found in the path list
}
}
else
{
// The pathIdCandidate is probably a real path. Leave alone.
}
}
}

View File

@ -107,6 +107,8 @@ public:
caf::PdmField<QString> plotWindowTreeViewState; caf::PdmField<QString> plotWindowTreeViewState;
caf::PdmField<QString> plotWindowCurrentModelIndexPath; caf::PdmField<QString> plotWindowCurrentModelIndexPath;
bool writeProjectFile();
void setScriptDirectories( const QString& scriptDirectories ); void setScriptDirectories( const QString& scriptDirectories );
void setPlotTemplateFolders( const QStringList& plotTemplateFolders ); void setPlotTemplateFolders( const QStringList& plotTemplateFolders );
@ -193,7 +195,11 @@ private:
template <typename T> template <typename T>
void fieldContentsByType( caf::PdmObjectHandle* object, std::vector<T*>& typedFields ); void fieldContentsByType( caf::PdmObjectHandle* object, std::vector<T*>& typedFields );
void transferPathsToGlobalPathList();
void distributePathsFromGlobalPathList();
private: private:
caf::PdmField<QString> m_globalPathList;
caf::PdmField<QString> m_projectFileVersionString; caf::PdmField<QString> m_projectFileVersionString;
caf::PdmChildField<RimDialogData*> m_dialogData; caf::PdmChildField<RimDialogData*> m_dialogData;

View File

@ -151,9 +151,9 @@ bool RimWellLogFile::readFile( QString* errorMessage )
m_wellLogDataFile = new RigWellLogFile; m_wellLogDataFile = new RigWellLogFile;
} }
m_name = QFileInfo( m_fileName ).fileName(); m_name = QFileInfo( m_fileName().path() ).fileName();
if ( !m_wellLogDataFile->open( m_fileName, errorMessage ) ) if ( !m_wellLogDataFile->open( m_fileName().path(), errorMessage ) )
{ {
m_wellLogDataFile = nullptr; m_wellLogDataFile = nullptr;
return false; return false;
@ -191,7 +191,7 @@ bool RimWellLogFile::readFile( QString* errorMessage )
this->firstAncestorOrThisOfType( wellPath ); this->firstAncestorOrThisOfType( wellPath );
if ( wellPath ) if ( wellPath )
{ {
if ( wellPath->filepath().isEmpty() ) // Has dummy wellpath if ( wellPath->filePath().isEmpty() ) // Has dummy wellpath
{ {
wellPath->setName( m_wellName ); wellPath->setName( m_wellName );
} }
@ -242,15 +242,15 @@ bool RimWellLogFile::hasFlowData() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellLogFile::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) void RimWellLogFile::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath )
{ {
bool foundFile = false; // bool foundFile = false;
std::vector<QString> searchedPaths; // std::vector<QString> searchedPaths;
//
QString fileNameCandidate = // QString fileNameCandidate =
RimTools::relocateFile( m_fileName(), newProjectPath, oldProjectPath, &foundFile, &searchedPaths ); // RimTools::relocateFile( m_fileName(), newProjectPath, oldProjectPath, &foundFile, &searchedPaths );
if ( foundFile ) // if ( foundFile )
{ // {
m_fileName = fileNameCandidate; // m_fileName = fileNameCandidate;
} // }
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -51,7 +51,7 @@ public:
void setFileName( const QString& fileName ); void setFileName( const QString& fileName );
QString fileName() const QString fileName() const
{ {
return m_fileName; return m_fileName().path();
} }
QString name() const QString name() const
{ {
@ -109,7 +109,7 @@ private:
private: private:
cvf::ref<RigWellLogFile> m_wellLogDataFile; cvf::ref<RigWellLogFile> m_wellLogDataFile;
caf::PdmField<QString> m_wellName; caf::PdmField<QString> m_wellName;
caf::PdmField<QString> m_fileName; caf::PdmField<caf::FilePath> m_fileName;
caf::PdmField<QString> m_name; caf::PdmField<QString> m_name;
caf::PdmField<QDateTime> m_date; caf::PdmField<QDateTime> m_date;
bool m_lasFileHasValidDate; bool m_lasFileHasValidDate;

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;

View File

@ -148,7 +148,7 @@ void RimWellPathCollection::loadDataAndUpdate()
RimModeledWellPath* mWPath = dynamic_cast<RimModeledWellPath*>( wellPaths[wpIdx] ); RimModeledWellPath* mWPath = dynamic_cast<RimModeledWellPath*>( wellPaths[wpIdx] );
if ( fWPath ) if ( fWPath )
{ {
if ( !fWPath->filepath().isEmpty() ) if ( !fWPath->filePath().isEmpty() )
{ {
QString errorMessage; QString errorMessage;
if ( !fWPath->readWellPathFile( &errorMessage, m_wellPathImporter ) ) if ( !fWPath->readWellPathFile( &errorMessage, m_wellPathImporter ) )
@ -221,7 +221,7 @@ std::vector<RimWellPath*> RimWellPathCollection::addWellPaths( QStringList fileP
f1.setFileName( filePath ); f1.setFileName( filePath );
QString s1 = f1.fileName(); QString s1 = f1.fileName();
QFile f2; QFile f2;
f2.setFileName( fWPath->filepath() ); f2.setFileName( fWPath->filePath() );
QString s2 = f2.fileName(); QString s2 = f2.fileName();
if ( s1 == s2 ) if ( s1 == s2 )
{ {
@ -285,7 +285,7 @@ void RimWellPathCollection::readAndAddWellPaths( std::vector<RimFileWellPath*>&
RimFileWellPath* existingWellPath = dynamic_cast<RimFileWellPath*>( tryFindMatchingWellPath( wellPath->name() ) ); RimFileWellPath* existingWellPath = dynamic_cast<RimFileWellPath*>( tryFindMatchingWellPath( wellPath->name() ) );
if ( existingWellPath ) if ( existingWellPath )
{ {
existingWellPath->setFilepath( wellPath->filepath() ); existingWellPath->setFilepath( wellPath->filePath() );
existingWellPath->setWellPathIndexInFile( wellPath->wellPathIndexInFile() ); existingWellPath->setWellPathIndexInFile( wellPath->wellPathIndexInFile() );
existingWellPath->readWellPathFile( nullptr, m_wellPathImporter ); existingWellPath->readWellPathFile( nullptr, m_wellPathImporter );
@ -596,7 +596,7 @@ void RimWellPathCollection::removeWellPath( RimWellPath* wellPath )
for ( size_t i = 0; i < wellPaths.size(); i++ ) for ( size_t i = 0; i < wellPaths.size(); i++ )
{ {
RimFileWellPath* fWPath = dynamic_cast<RimFileWellPath*>( wellPaths[i] ); RimFileWellPath* fWPath = dynamic_cast<RimFileWellPath*>( wellPaths[i] );
if ( fWPath && fWPath->filepath() == fileWellPath->filepath() ) if ( fWPath && fWPath->filePath() == fileWellPath->filePath() )
{ {
isFilePathUsed = true; isFilePathUsed = true;
break; break;
@ -607,7 +607,7 @@ void RimWellPathCollection::removeWellPath( RimWellPath* wellPath )
{ {
// One file can have multiple well paths // One file can have multiple well paths
// If no other well paths are referencing the filepath, remove cached data from the file reader // If no other well paths are referencing the filepath, remove cached data from the file reader
m_wellPathImporter->removeFilePath( fileWellPath->filepath() ); m_wellPathImporter->removeFilePath( fileWellPath->filePath() );
} }
} }
updateAllRequiredEditors(); updateAllRequiredEditors();

View File

@ -56,7 +56,7 @@ RimFileSummaryCase::~RimFileSummaryCase() {}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QString RimFileSummaryCase::summaryHeaderFilename() const QString RimFileSummaryCase::summaryHeaderFilename() const
{ {
return m_summaryHeaderFilename(); return m_summaryHeaderFilename().path();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -74,8 +74,8 @@ QString RimFileSummaryCase::caseName() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimFileSummaryCase::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) void RimFileSummaryCase::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath )
{ {
m_summaryHeaderFilename = // m_summaryHeaderFilename =
RimTools::relocateFile( m_summaryHeaderFilename(), newProjectPath, oldProjectPath, nullptr, nullptr ); // RimTools::relocateFile( m_summaryHeaderFilename().path(), newProjectPath, oldProjectPath, nullptr, nullptr );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -115,7 +115,7 @@ RimEclipseCase* RimGridSummaryCase::associatedEclipseCase()
if ( eclCase ) if ( eclCase )
{ {
QString sumHeaderFileName = summaryHeaderFilenameFromEclipseCase( eclCase ); QString sumHeaderFileName = summaryHeaderFilenameFromEclipseCase( eclCase );
if ( sumHeaderFileName == m_summaryHeaderFilename ) if ( sumHeaderFileName == m_summaryHeaderFilename().path() )
{ {
m_eclipseCase = eclCase; m_eclipseCase = eclCase;
this->updateAutoShortName(); this->updateAutoShortName();
@ -135,7 +135,7 @@ RimEclipseCase* RimGridSummaryCase::associatedEclipseCase()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QString RimGridSummaryCase::summaryHeaderFilename() const QString RimGridSummaryCase::summaryHeaderFilename() const
{ {
if ( !m_eclipseCase() ) return m_summaryHeaderFilename(); if ( !m_eclipseCase() ) return m_summaryHeaderFilename().path();
return summaryHeaderFilenameFromEclipseCase( m_eclipseCase() ); return summaryHeaderFilenameFromEclipseCase( m_eclipseCase() );
} }

View File

@ -68,8 +68,8 @@ QString RimObservedSummaryData::caseName() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimObservedSummaryData::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) void RimObservedSummaryData::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath )
{ {
m_summaryHeaderFilename = // m_summaryHeaderFilename =
RimTools::relocateFile( m_summaryHeaderFilename(), newProjectPath, oldProjectPath, nullptr, nullptr ); // RimTools::relocateFile( m_summaryHeaderFilename(), newProjectPath, oldProjectPath, nullptr, nullptr );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -62,7 +62,7 @@ RimSummaryCase::~RimSummaryCase() {}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QString RimSummaryCase::summaryHeaderFilename() const QString RimSummaryCase::summaryHeaderFilename() const
{ {
return m_summaryHeaderFilename(); return m_summaryHeaderFilename().path();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -20,6 +20,7 @@
#include "RiaEclipseUnitTools.h" #include "RiaEclipseUnitTools.h"
#include "RigCaseRealizationParameters.h" #include "RigCaseRealizationParameters.h"
#include "cafFilePath.h"
#include "cafPdmField.h" #include "cafPdmField.h"
#include "cafPdmObject.h" #include "cafPdmObject.h"
@ -81,10 +82,10 @@ protected:
const QVariant& newValue ) override; const QVariant& newValue ) override;
void updateTreeItemName(); void updateTreeItemName();
caf::PdmField<QString> m_shortName; caf::PdmField<QString> m_shortName;
caf::PdmField<bool> m_useAutoShortName; caf::PdmField<bool> m_useAutoShortName;
caf::PdmField<QString> m_summaryHeaderFilename; caf::PdmField<caf::FilePath> m_summaryHeaderFilename;
bool m_isObservedData; bool m_isObservedData;
std::shared_ptr<RigCaseRealizationParameters> m_crlParameters; std::shared_ptr<RigCaseRealizationParameters> m_crlParameters;

View File

@ -568,7 +568,7 @@ public:
inputProperty = new RimEclipseInputProperty; inputProperty = new RimEclipseInputProperty;
inputProperty->resultName = m_currentPropertyName; inputProperty->resultName = m_currentPropertyName;
inputProperty->eclipseKeyword = ""; inputProperty->eclipseKeyword = "";
inputProperty->fileName = ""; inputProperty->fileName = QString( "" );
inputRes->inputPropertyCollection()->inputProperties.push_back( inputProperty ); inputRes->inputPropertyCollection()->inputProperties.push_back( inputProperty );
inputRes->inputPropertyCollection()->updateConnectedEditors(); inputRes->inputPropertyCollection()->updateConnectedEditors();
} }

View File

@ -689,7 +689,7 @@ public:
inputProperty = new RimEclipseInputProperty; inputProperty = new RimEclipseInputProperty;
inputProperty->resultName = m_currentPropertyName; inputProperty->resultName = m_currentPropertyName;
inputProperty->eclipseKeyword = ""; inputProperty->eclipseKeyword = "";
inputProperty->fileName = ""; inputProperty->fileName = QString( "" );
inputRes->inputPropertyCollection()->inputProperties.push_back( inputProperty ); inputRes->inputPropertyCollection()->inputProperties.push_back( inputProperty );
inputRes->inputPropertyCollection()->updateConnectedEditors(); inputRes->inputPropertyCollection()->updateConnectedEditors();
} }
@ -1080,7 +1080,7 @@ public:
inputProperty = new RimEclipseInputProperty; inputProperty = new RimEclipseInputProperty;
inputProperty->resultName = m_currentPropertyName; inputProperty->resultName = m_currentPropertyName;
inputProperty->eclipseKeyword = ""; inputProperty->eclipseKeyword = "";
inputProperty->fileName = ""; inputProperty->fileName = QString( "" );
inputRes->inputPropertyCollection()->inputProperties.push_back( inputProperty ); inputRes->inputPropertyCollection()->inputProperties.push_back( inputProperty );
inputRes->inputPropertyCollection()->updateConnectedEditors(); inputRes->inputPropertyCollection()->updateConnectedEditors();
} }

View File

@ -162,7 +162,7 @@ public:
static bool isEqual(const QVariant& variantValue, const QVariant& variantValue2) static bool isEqual(const QVariant& variantValue, const QVariant& variantValue2)
{ {
return variantValue.value<FilePath>() == variantValue2.value<FilePath>(); return variantValue.toString() == variantValue2.toString();
} }
}; };