From a9d089df6d9e1b70c0abea065a3811fade7214cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 10 Dec 2019 14:58:47 +0100 Subject: [PATCH 01/19] #5147 PdmField now uses a reference list in the start of the project file to store the paths. --- .../Application/RiaApplication.cpp | 4 +- .../ProjectDataModel/RimProject.cpp | 217 ++++++++++++++++++ ApplicationCode/ProjectDataModel/RimProject.h | 6 + 3 files changed, 225 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 19babbd370..f9302bf28c 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -316,7 +316,7 @@ bool RiaApplication::openFile( const QString& fileName ) } else if ( fileType & RiaDefines::ANY_ECLIPSE_FILE ) { - loadingSucceded = RicImportGeneralDataFeature::openEclipseFilesFromFileNames( QStringList{ fileName }, true ); + loadingSucceded = RicImportGeneralDataFeature::openEclipseFilesFromFileNames( QStringList{fileName}, true ); lastUsedDialogTag = RiaDefines::defaultDirectoryLabel( fileType ); } @@ -701,7 +701,7 @@ bool RiaApplication::saveProjectAs( const QString& fileName, QString* errorMessa onProjectBeingSaved(); - if ( !m_project->writeFile() ) + if ( !m_project->writeProjectFile() ) { CAF_ASSERT( errorMessage ); *errorMessage = QString( "Not possible to save project file. Make sure you have sufficient access " diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 2f2e2f5e97..043455864d 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -96,6 +96,7 @@ #include #include #include +#include CAF_PDM_SOURCE_INIT( RimProject, "ResInsightProject" ); //-------------------------------------------------------------------------------------------------- @@ -112,6 +113,9 @@ RimProject::RimProject( void ) CAF_PDM_InitFieldNoDefault( &m_projectFileVersionString, "ProjectFileVersionString", "", "", "", "" ); m_projectFileVersionString.uiCapability()->setUiHidden( true ); + CAF_PDM_InitFieldNoDefault( &m_globalPathList, "ReferencedExternalFiles", "", "", "", "" ); + m_globalPathList.uiCapability()->setUiHidden( true ); + CAF_PDM_InitFieldNoDefault( &oilFields, "OilFields", "Oil Fields", "", "", "" ); oilFields.uiCapability()->setUiHidden( true ); @@ -254,6 +258,8 @@ void RimProject::close() //-------------------------------------------------------------------------------------------------- void RimProject::initAfterRead() { + this->distributePathsFromGlobalPathList(); + // Create an empty oil field in case the project did not contain one if ( oilFields.size() < 1 ) { @@ -329,6 +335,18 @@ void RimProject::setupBeforeSave() m_projectFileVersionString = STRPRODUCTVER; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimProject::writeProjectFile() +{ + this->transferPathsToGlobalPathList(); + bool couldOpenFile = this->writeFile(); + this->distributePathsFromGlobalPathList(); + + return couldOpenFile; +} + //-------------------------------------------------------------------------------------------------- /// Support list of multiple script paths divided by ';' //-------------------------------------------------------------------------------------------------- @@ -1349,3 +1367,202 @@ void RimProject::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, Q 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 pathIdentifier = PATHIDCHAR + pathIdBaseString + QString::number( m_nextValidIdNumber ) + PATHIDCHAR; + m_nextValidIdNumber++; + return pathIdentifier; + } + + size_t m_nextValidIdNumber; // Set when parsing the globalPathListTable. Increment while creating new id's + + std::map m_newPathIdToPathMap; + std::map m_newPathToPathIdMap; + + std::map m_oldPathIdToPathMap; + std::map m_oldPathToPathIdMap; +}; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimProject::transferPathsToGlobalPathList() +{ + GlobalPathListMapper pathListMapper( m_globalPathList() ); + + std::vector 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 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. + } + } +} diff --git a/ApplicationCode/ProjectDataModel/RimProject.h b/ApplicationCode/ProjectDataModel/RimProject.h index 302851a3a9..35229cba20 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.h +++ b/ApplicationCode/ProjectDataModel/RimProject.h @@ -106,6 +106,8 @@ public: caf::PdmField plotWindowTreeViewState; caf::PdmField plotWindowCurrentModelIndexPath; + bool writeProjectFile(); + void setScriptDirectories( const QString& scriptDirectories ); void setPlotTemplateFolders( const QStringList& plotTemplateFolders ); @@ -191,7 +193,11 @@ private: template void fieldContentsByType( caf::PdmObjectHandle* object, std::vector& typedFields ); + void transferPathsToGlobalPathList(); + void distributePathsFromGlobalPathList(); + private: + caf::PdmField m_globalPathList; caf::PdmField m_projectFileVersionString; caf::PdmChildField m_dialogData; From 18cf59530f97471c9278eb6672c31fd17c600238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 10 Dec 2019 16:12:21 +0100 Subject: [PATCH 02/19] #5147 RimSummaryCase::m_summaryHeaderFilename -> PdmField --- .../ProjectDataModel/Summary/RimFileSummaryCase.cpp | 6 +++--- .../ProjectDataModel/Summary/RimGridSummaryCase.cpp | 4 ++-- .../ProjectDataModel/Summary/RimObservedSummaryData.cpp | 4 ++-- .../ProjectDataModel/Summary/RimSummaryCase.cpp | 2 +- .../ProjectDataModel/Summary/RimSummaryCase.h | 9 +++++---- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimFileSummaryCase.cpp b/ApplicationCode/ProjectDataModel/Summary/RimFileSummaryCase.cpp index 67671726bf..9c2921fa0f 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimFileSummaryCase.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimFileSummaryCase.cpp @@ -56,7 +56,7 @@ RimFileSummaryCase::~RimFileSummaryCase() {} //-------------------------------------------------------------------------------------------------- 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 ) { - m_summaryHeaderFilename = - RimTools::relocateFile( m_summaryHeaderFilename(), newProjectPath, oldProjectPath, nullptr, nullptr ); + // m_summaryHeaderFilename = + // RimTools::relocateFile( m_summaryHeaderFilename().path(), newProjectPath, oldProjectPath, nullptr, nullptr ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimGridSummaryCase.cpp b/ApplicationCode/ProjectDataModel/Summary/RimGridSummaryCase.cpp index c5f5eac66e..e147d2dda5 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimGridSummaryCase.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimGridSummaryCase.cpp @@ -115,7 +115,7 @@ RimEclipseCase* RimGridSummaryCase::associatedEclipseCase() if ( eclCase ) { QString sumHeaderFileName = summaryHeaderFilenameFromEclipseCase( eclCase ); - if ( sumHeaderFileName == m_summaryHeaderFilename ) + if ( sumHeaderFileName == m_summaryHeaderFilename().path() ) { m_eclipseCase = eclCase; this->updateAutoShortName(); @@ -135,7 +135,7 @@ RimEclipseCase* RimGridSummaryCase::associatedEclipseCase() //-------------------------------------------------------------------------------------------------- QString RimGridSummaryCase::summaryHeaderFilename() const { - if ( !m_eclipseCase() ) return m_summaryHeaderFilename(); + if ( !m_eclipseCase() ) return m_summaryHeaderFilename().path(); return summaryHeaderFilenameFromEclipseCase( m_eclipseCase() ); } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimObservedSummaryData.cpp b/ApplicationCode/ProjectDataModel/Summary/RimObservedSummaryData.cpp index eddfad1697..c593c1c4c5 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimObservedSummaryData.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimObservedSummaryData.cpp @@ -68,8 +68,8 @@ QString RimObservedSummaryData::caseName() const //-------------------------------------------------------------------------------------------------- void RimObservedSummaryData::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) { - m_summaryHeaderFilename = - RimTools::relocateFile( m_summaryHeaderFilename(), newProjectPath, oldProjectPath, nullptr, nullptr ); + // m_summaryHeaderFilename = + // RimTools::relocateFile( m_summaryHeaderFilename(), newProjectPath, oldProjectPath, nullptr, nullptr ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp index 764617e10b..d9bf66e234 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp @@ -62,7 +62,7 @@ RimSummaryCase::~RimSummaryCase() {} //-------------------------------------------------------------------------------------------------- QString RimSummaryCase::summaryHeaderFilename() const { - return m_summaryHeaderFilename(); + return m_summaryHeaderFilename().path(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.h index 2214cee0ee..87e46a3c8c 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.h @@ -20,6 +20,7 @@ #include "RiaEclipseUnitTools.h" #include "RigCaseRealizationParameters.h" +#include "cafFilePath.h" #include "cafPdmField.h" #include "cafPdmObject.h" @@ -81,10 +82,10 @@ protected: const QVariant& newValue ) override; void updateTreeItemName(); - caf::PdmField m_shortName; - caf::PdmField m_useAutoShortName; - caf::PdmField m_summaryHeaderFilename; - bool m_isObservedData; + caf::PdmField m_shortName; + caf::PdmField m_useAutoShortName; + caf::PdmField m_summaryHeaderFilename; + bool m_isObservedData; std::shared_ptr m_crlParameters; From d19c87c23ab24b30626e27e070ec5aa3d17012c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 10 Dec 2019 16:19:39 +0100 Subject: [PATCH 03/19] #5147 RimEclipseResultCase::caseFileName -> PdmField --- .../ProjectDataModel/RimEclipseResultCase.cpp | 33 ++++++++++--------- .../ProjectDataModel/RimEclipseResultCase.h | 5 +-- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp index fce2afd4da..9db0687f2c 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp @@ -72,7 +72,7 @@ RimEclipseResultCase::RimEclipseResultCase() { 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.capability()->setIOWriteable( false ); @@ -127,13 +127,13 @@ bool RimEclipseResultCase::importGridAndResultMetaData( bool showTimeStepFilter cvf::ref 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 { - if ( !caf::Utils::fileExists( caseFileName() ) ) + if ( !caf::Utils::fileExists( caseFileName().path() ) ) { return false; } @@ -142,7 +142,7 @@ bool RimEclipseResultCase::importGridAndResultMetaData( bool showTimeStepFilter readerEclipseOutput->setFilenamesWithFaults( this->filesContainingFaults() ); cvf::ref restartDataAccess = RifEclipseOutputFileTools::createDynamicResultAccess( - caseFileName() ); + caseFileName().path() ); { std::vector timeSteps; @@ -177,11 +177,12 @@ bool RimEclipseResultCase::importGridAndResultMetaData( bool showTimeStepFilter } m_timeStepFilter->updateFilteredTimeStepsFromUi(); } + readerEclipseOutput->setFileDataAccess( restartDataAccess.p() ); readerEclipseOutput->setTimeStepFilter( m_timeStepFilter->filteredTimeSteps() ); cvf::ref eclipseCase = new RigEclipseCaseData( this ); - if ( !readerEclipseOutput->open( caseFileName(), eclipseCase.p() ) ) + if ( !readerEclipseOutput->open( caseFileName().path(), eclipseCase.p() ) ) { return false; } @@ -209,7 +210,7 @@ bool RimEclipseResultCase::importGridAndResultMetaData( bool showTimeStepFilter m_gridAndWellDataIsReadFromFile = true; m_activeCellInfoIsReadFromFile = true; - QFileInfo eclipseCaseFileInfo( caseFileName() ); + QFileInfo eclipseCaseFileInfo( caseFileName().path() ); QString rftFileName = eclipseCaseFileInfo.path() + "/" + eclipseCaseFileInfo.completeBaseName() + ".RFT"; QFileInfo rftFileInfo( rftFileName ); @@ -274,13 +275,13 @@ bool RimEclipseResultCase::openAndReadActiveCellData( RigEclipseCaseData* mainEc if ( m_activeCellInfoIsReadFromFile ) return true; cvf::ref 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 { - if ( !caf::Utils::fileExists( caseFileName() ) ) + if ( !caf::Utils::fileExists( caseFileName().path() ) ) { return false; } @@ -292,7 +293,7 @@ bool RimEclipseResultCase::openAndReadActiveCellData( RigEclipseCaseData* mainEc std::vector timeStepDates = mainEclipseCase->results( RiaDefines::MATRIX_MODEL )->timeStepDates(); cvf::ref readerEclipseOutput = new RifReaderEclipseOutput; - if ( !readerEclipseOutput->openAndReadActiveCellData( caseFileName(), timeStepDates, eclipseCase.p() ) ) + if ( !readerEclipseOutput->openAndReadActiveCellData( caseFileName().path(), timeStepDates, eclipseCase.p() ) ) { return false; } @@ -468,7 +469,7 @@ RimEclipseResultCase::~RimEclipseResultCase() //-------------------------------------------------------------------------------------------------- QString RimEclipseResultCase::locationOnDisc() const { - QFileInfo fi( caseFileName() ); + QFileInfo fi( caseFileName().path() ); return fi.absolutePath(); } @@ -477,7 +478,7 @@ QString RimEclipseResultCase::locationOnDisc() const //-------------------------------------------------------------------------------------------------- void RimEclipseResultCase::readGridDimensions( std::vector>& gridDimensions ) { - RifEclipseOutputFileTools::readGridDimensions( caseFileName(), gridDimensions ); + RifEclipseOutputFileTools::readGridDimensions( caseFileName().path(), gridDimensions ); } //-------------------------------------------------------------------------------------------------- @@ -489,7 +490,7 @@ void RimEclipseResultCase::updateFilePathsFromProjectPath( const QString& newPro std::vector searchedPaths; // 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 relocatedFaultFiles; const std::vector& orgFilesContainingFaults = filesContainingFaults(); @@ -597,7 +598,7 @@ void RimEclipseResultCase::initAfterRead() RimEclipseCase::initAfterRead(); // 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() ) { @@ -658,7 +659,7 @@ void RimEclipseResultCase::defineEditorAttribute( const caf::PdmFieldHandle* fie if ( myAttr ) { myAttr->m_fileSelectionFilter = "SourSim (*.sourres)"; - myAttr->m_defaultPath = QFileInfo( caseFileName() ).absolutePath(); + myAttr->m_defaultPath = QFileInfo( caseFileName().path() ).absolutePath(); } } } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultCase.h b/ApplicationCode/ProjectDataModel/RimEclipseResultCase.h index 336d852b5d..699c6f4745 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultCase.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultCase.h @@ -24,6 +24,7 @@ #include "RimEclipseCase.h" +#include "cafFilePath.h" #include class RifReaderEclipseRft; @@ -65,7 +66,7 @@ public: QString locationOnDisc() const override; QString gridFileName() const override { - return caseFileName(); + return caseFileName().path(); } void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) override; @@ -98,7 +99,7 @@ private: cvf::ref m_readerEclipseRft; // Fields: - caf::PdmField caseFileName; + caf::PdmField caseFileName; caf::PdmProxyValueField m_unitSystem; caf::PdmChildArrayField m_flowDiagSolutions; caf::PdmField m_sourSimFileName; From 723caaaf79e7cfee6e786d1d6f1ccf8179a1ff92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 10 Dec 2019 16:36:07 +0100 Subject: [PATCH 04/19] #5147 RimEclipseCase::m_filesContainingFaults -> vector --- .../ProjectDataModel/RimEclipseCase.cpp | 29 ++++++++----------- .../ProjectDataModel/RimEclipseCase.h | 4 +-- .../ProjectDataModel/RimEclipseResultCase.cpp | 24 +++++++-------- 3 files changed, 26 insertions(+), 31 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp index 4486c5a5ec..770ac6cfcd 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp @@ -89,8 +89,8 @@ RimEclipseCase::RimEclipseCase() CAF_PDM_InitField( &m_flipXAxis, "FlipXAxis", false, "Flip X Axis", "", "", "" ); CAF_PDM_InitField( &m_flipYAxis, "FlipYAxis", false, "Flip Y Axis", "", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_filesContainingFaultsSemColSeparated, "CachedFileNamesContainingFaults", "", "", "", "" ); - m_filesContainingFaultsSemColSeparated.uiCapability()->setUiHidden( true ); + CAF_PDM_InitFieldNoDefault( &m_filesContainingFaults, "CachedFileNamesContainingFaults", "", "", "", "" ); + m_filesContainingFaults.uiCapability()->setUiHidden( true ); CAF_PDM_InitFieldNoDefault( &m_contourMapCollection, "ContourMaps", "2d Contour Maps", "", "", "" ); m_contourMapCollection = new RimEclipseContourMapViewCollection; @@ -746,12 +746,12 @@ const RimReservoirCellResultsStorage* RimEclipseCase::resultsStorage( RiaDefines //-------------------------------------------------------------------------------------------------- std::vector RimEclipseCase::filesContainingFaults() const { - QString separatedPaths = m_filesContainingFaultsSemColSeparated; - QStringList pathList = separatedPaths.split( ";", QString::SkipEmptyParts ); std::vector stdPathList; - for ( auto& path : pathList ) - stdPathList.push_back( path ); + for ( auto& filePath : m_filesContainingFaults() ) + { + stdPathList.push_back( filePath.path() ); + } return stdPathList; } @@ -759,20 +759,15 @@ std::vector RimEclipseCase::filesContainingFaults() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEclipseCase::setFilesContainingFaults( const std::vector& val ) +void RimEclipseCase::setFilesContainingFaults( const std::vector& pathStrings ) { - QString separatedPaths; - - for ( size_t i = 0; i < val.size(); ++i ) + std::vector filePaths; + for ( const auto& pathString : pathStrings ) { - const auto& path = val[i]; - separatedPaths += path; - if ( !( i + 1 >= val.size() ) ) - { - separatedPaths += ";"; - } + filePaths.push_back( pathString ); } - m_filesContainingFaultsSemColSeparated = separatedPaths; + + m_filesContainingFaults = filePaths; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.h b/ApplicationCode/ProjectDataModel/RimEclipseCase.h index 76f58702ea..fd067d01f7 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.h @@ -145,8 +145,8 @@ protected: caf::PdmChildField m_inputPropertyCollection; private: - caf::PdmField m_filesContainingFaultsSemColSeparated; - caf::PdmField m_releaseResultMemory; + caf::PdmField> m_filesContainingFaults; + caf::PdmField m_releaseResultMemory; caf::PdmChildField m_contourMapCollection; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp index 9db0687f2c..123bf2a0eb 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp @@ -486,22 +486,22 @@ void RimEclipseResultCase::readGridDimensions( std::vector>& gr //-------------------------------------------------------------------------------------------------- void RimEclipseResultCase::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) { - bool foundFile = false; - std::vector searchedPaths; + // bool foundFile = false; + // std::vector searchedPaths; // Update filename and folder paths when opening project from a different file location // caseFileName = RimTools::relocateFile( caseFileName().path(), newProjectPath, oldProjectPath, &foundFile, &searchedPaths ); - std::vector relocatedFaultFiles; - const std::vector& orgFilesContainingFaults = filesContainingFaults(); - for ( auto faultFileName : orgFilesContainingFaults ) - { - QString relocatedFaultFile = - RimTools::relocateFile( faultFileName, newProjectPath, oldProjectPath, &foundFile, &searchedPaths ); - relocatedFaultFiles.push_back( relocatedFaultFile ); - } - - setFilesContainingFaults( relocatedFaultFiles ); + // std::vector relocatedFaultFiles; + // const std::vector& orgFilesContainingFaults = filesContainingFaults(); + // for ( auto faultFileName : orgFilesContainingFaults ) + // { + // QString relocatedFaultFile = + // RimTools::relocateFile( faultFileName, newProjectPath, oldProjectPath, &foundFile, &searchedPaths ); + // relocatedFaultFiles.push_back( relocatedFaultFile ); + // } + // + // setFilesContainingFaults( relocatedFaultFiles ); #if 0 // Output the search path for debugging for (size_t i = 0; i < searchedPaths.size(); ++i) From 11807029a5b9e68e3cd0d86b999a647911ce2564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 10 Dec 2019 16:43:12 +0100 Subject: [PATCH 05/19] #5147 RimEclipseInputCase::m_gridFileName -> FilePath --- .../ProjectDataModel/RimEclipseInputCase.cpp | 20 +++++++++---------- .../ProjectDataModel/RimEclipseInputCase.h | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseInputCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseInputCase.cpp index 533fa7dfd2..fd756ea7d6 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseInputCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseInputCase.cpp @@ -55,7 +55,7 @@ RimEclipseInputCase::RimEclipseInputCase() : RimEclipseCase() { 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 ); CAF_PDM_InitFieldNoDefault( &m_additionalFiles, "AdditionalFileNamesProxy", "Additional Files", "", "", "" ); @@ -190,16 +190,16 @@ bool RimEclipseInputCase::openEclipseGridFile() { cvf::ref 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 { readerInterface = new RifReaderEclipseInput; cvf::ref eclipseCase = new RigEclipseCaseData( this ); - if ( !readerInterface->open( m_gridFileName, eclipseCase.p() ) ) + if ( !readerInterface->open( m_gridFileName().path(), eclipseCase.p() ) ) { return false; } @@ -258,7 +258,7 @@ void RimEclipseInputCase::loadAndSyncronizeInputProperties() { filenames.push_back( fileName ); } - filenames.push_back( m_gridFileName ); + filenames.push_back( m_gridFileName().path() ); RifEclipseInputPropertyLoader::loadAndSyncronizeInputProperties( inputPropertyCollection(), eclipseCaseData(), @@ -332,9 +332,9 @@ void RimEclipseInputCase::defineUiOrdering( QString uiConfigName, caf::PdmUiOrde //-------------------------------------------------------------------------------------------------- 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(); } @@ -346,7 +346,7 @@ void RimEclipseInputCase::updateFilePathsFromProjectPath( const QString& newProj bool foundFile = false; std::vector 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() ) { @@ -366,7 +366,7 @@ void RimEclipseInputCase::updateAdditionalFileFolder( const QString& newFolder ) QDir newDir( newFolder ); for ( RimEclipseInputProperty* inputProperty : m_inputPropertyCollection()->inputProperties() ) { - if ( inputProperty->fileName == m_gridFileName ) continue; + if ( inputProperty->fileName == m_gridFileName().path() ) continue; QFileInfo oldFilePath( inputProperty->fileName ); QFileInfo newFilePath( newDir, oldFilePath.fileName() ); inputProperty->fileName = newFilePath.absoluteFilePath(); @@ -381,7 +381,7 @@ std::vector RimEclipseInputCase::additionalFiles() const std::vector additionalFiles; 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 ); } return additionalFiles; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseInputCase.h b/ApplicationCode/ProjectDataModel/RimEclipseInputCase.h index 82e1bb8687..3af67d5760 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseInputCase.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseInputCase.h @@ -57,7 +57,7 @@ public: QString locationOnDisc() const override; QString gridFileName() const override { - return m_gridFileName(); + return m_gridFileName().path(); } void updateFilePathsFromProjectPath( const QString& projectPath, const QString& oldProjectPath ) override; @@ -75,7 +75,7 @@ private: private: // Fields - caf::PdmField m_gridFileName; + caf::PdmField m_gridFileName; caf::PdmProxyValueField> m_additionalFiles; // Obsolete fields From 059288ef9718d88531128718d1ae3054e5802fd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 10 Dec 2019 16:58:07 +0100 Subject: [PATCH 06/19] #5147 RimEclipseInputProperty::fileName -> caf::FilePath --- .../RicSaveEclipseInputPropertyFeature.cpp | 2 +- .../ProjectDataModel/RimEclipseInputCase.cpp | 29 ++++++++++--------- .../RimEclipseInputProperty.cpp | 2 +- .../RimEclipseInputProperty.h | 7 +++-- .../RimEclipseInputPropertyCollection.cpp | 2 +- .../SocketInterface/RiaNNCCommands.cpp | 2 +- .../RiaPropertyDataCommands.cpp | 4 +-- 7 files changed, 26 insertions(+), 22 deletions(-) diff --git a/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputPropertyFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputPropertyFeature.cpp index 5f35e9042c..c9c23b3413 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputPropertyFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputPropertyFeature.cpp @@ -125,7 +125,7 @@ void RicSaveEclipseInputPropertyFeature::onActionTriggered( bool isChecked ) &errorMsg ); if ( isOk ) { - inputProperty->fileName = exportSettings.fileName; + inputProperty->fileName = exportSettings.fileName(); inputProperty->eclipseKeyword = exportSettings.eclipseKeyword; inputProperty->resolvedState = RimEclipseInputProperty::RESOLVED; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseInputCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseInputCase.cpp index fd756ea7d6..595c47c65e 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseInputCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseInputCase.cpp @@ -302,7 +302,7 @@ cvf::ref RimEclipseInputCase::createMockModel( QString model RimEclipseInputProperty* inputProperty = new RimEclipseInputProperty; inputProperty->resultName = "PORO"; inputProperty->eclipseKeyword = "PORO"; - inputProperty->fileName = "PORO.prop"; + inputProperty->fileName = QString( "PORO.prop" ); m_inputPropertyCollection->inputProperties.push_back( inputProperty ); } @@ -343,19 +343,19 @@ QString RimEclipseInputCase::locationOnDisc() const //-------------------------------------------------------------------------------------------------- void RimEclipseInputCase::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) { - bool foundFile = false; - std::vector searchedPaths; + // bool foundFile = false; + // std::vector searchedPaths; // m_gridFileName = RimTools::relocateFile( m_gridFileName().path(), newProjectPath, oldProjectPath, &foundFile, &searchedPaths ); - for ( RimEclipseInputProperty* inputProperty : m_inputPropertyCollection()->inputProperties() ) - { - inputProperty->fileName = RimTools::relocateFile( inputProperty->fileName, - newProjectPath, - oldProjectPath, - &foundFile, - &searchedPaths ); - } + // for ( RimEclipseInputProperty* inputProperty : m_inputPropertyCollection()->inputProperties() ) + //{ + // inputProperty->fileName = RimTools::relocateFile( inputProperty->fileName, + // newProjectPath, + // oldProjectPath, + // &foundFile, + // &searchedPaths ); + //} } //-------------------------------------------------------------------------------------------------- @@ -367,7 +367,8 @@ void RimEclipseInputCase::updateAdditionalFileFolder( const QString& newFolder ) for ( RimEclipseInputProperty* inputProperty : m_inputPropertyCollection()->inputProperties() ) { if ( inputProperty->fileName == m_gridFileName().path() ) continue; - QFileInfo oldFilePath( inputProperty->fileName ); + + QFileInfo oldFilePath( inputProperty->fileName().path() ); QFileInfo newFilePath( newDir, oldFilePath.fileName() ); inputProperty->fileName = newFilePath.absoluteFilePath(); } @@ -382,7 +383,9 @@ std::vector RimEclipseInputCase::additionalFiles() const for ( const RimEclipseInputProperty* inputProperty : m_inputPropertyCollection()->inputProperties() ) { if ( inputProperty->fileName == m_gridFileName().path() ) continue; - additionalFiles.push_back( inputProperty->fileName ); + + additionalFiles.push_back( inputProperty->fileName().path() ); } + return additionalFiles; } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseInputProperty.cpp b/ApplicationCode/ProjectDataModel/RimEclipseInputProperty.cpp index 6118c0ff60..aaab32648d 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseInputProperty.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseInputProperty.cpp @@ -58,7 +58,7 @@ RimEclipseInputProperty::RimEclipseInputProperty() CAF_PDM_InitField( &resultName, "ResultName", QString(), "Result Name", "", "", "" ); 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", "", "", "" ); resolvedState.uiCapability()->setUiReadOnly( true ); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseInputProperty.h b/ApplicationCode/ProjectDataModel/RimEclipseInputProperty.h index 46993901fa..78376b4e9f 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseInputProperty.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseInputProperty.h @@ -49,9 +49,10 @@ public: typedef caf::AppEnum ResolveStateEnum; // Fields: - caf::PdmField resultName; - caf::PdmField eclipseKeyword; - caf::PdmField fileName; // ReadOnly Serves as key to syncronize read eclipse prop data and this inputProp object. + caf::PdmField resultName; + caf::PdmField eclipseKeyword; + caf::PdmField fileName; // ReadOnly Serves as key to syncronize + // read eclipse prop data and this inputProp object. caf::PdmField resolvedState; // ReadOnly and not writable // PdmObject Overrides diff --git a/ApplicationCode/ProjectDataModel/RimEclipseInputPropertyCollection.cpp b/ApplicationCode/ProjectDataModel/RimEclipseInputPropertyCollection.cpp index eaff4b65f8..5271ac21c9 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseInputPropertyCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseInputPropertyCollection.cpp @@ -56,7 +56,7 @@ std::vector RimEclipseInputPropertyCollection::findInp { if ( !inputProperties[i] ) continue; - QFileInfo propFile( inputProperties[i]->fileName() ); + QFileInfo propFile( inputProperties[i]->fileName().path() ); if ( fileInfo == propFile ) result.push_back( inputProperties[i] ); } diff --git a/ApplicationCode/SocketInterface/RiaNNCCommands.cpp b/ApplicationCode/SocketInterface/RiaNNCCommands.cpp index 6f8b442895..0845226cc6 100644 --- a/ApplicationCode/SocketInterface/RiaNNCCommands.cpp +++ b/ApplicationCode/SocketInterface/RiaNNCCommands.cpp @@ -568,7 +568,7 @@ public: inputProperty = new RimEclipseInputProperty; inputProperty->resultName = m_currentPropertyName; inputProperty->eclipseKeyword = ""; - inputProperty->fileName = ""; + inputProperty->fileName = QString( "" ); inputRes->inputPropertyCollection()->inputProperties.push_back( inputProperty ); inputRes->inputPropertyCollection()->updateConnectedEditors(); } diff --git a/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp b/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp index 6da35c4f2c..e91cc3f16b 100644 --- a/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp +++ b/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp @@ -689,7 +689,7 @@ public: inputProperty = new RimEclipseInputProperty; inputProperty->resultName = m_currentPropertyName; inputProperty->eclipseKeyword = ""; - inputProperty->fileName = ""; + inputProperty->fileName = QString( "" ); inputRes->inputPropertyCollection()->inputProperties.push_back( inputProperty ); inputRes->inputPropertyCollection()->updateConnectedEditors(); } @@ -1080,7 +1080,7 @@ public: inputProperty = new RimEclipseInputProperty; inputProperty->resultName = m_currentPropertyName; inputProperty->eclipseKeyword = ""; - inputProperty->fileName = ""; + inputProperty->fileName = QString( "" ); inputRes->inputPropertyCollection()->inputProperties.push_back( inputProperty ); inputRes->inputPropertyCollection()->updateConnectedEditors(); } From eb421db0405963957fcaad80163a603f8b620c89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 11 Dec 2019 08:23:37 +0100 Subject: [PATCH 07/19] #5147 RimWellPath::m_wellPathFormationFilePath ->FilePath RimFileWellPath::m_filepath ->FilePath --- .../ProjectDataModel/RimFileWellPath.cpp | 34 ++++++------- .../ProjectDataModel/RimFileWellPath.h | 4 +- .../ProjectDataModel/RimWellPath.cpp | 48 ++++++++++--------- .../ProjectDataModel/RimWellPath.h | 5 +- 4 files changed, 48 insertions(+), 43 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimFileWellPath.cpp b/ApplicationCode/ProjectDataModel/RimFileWellPath.cpp index f05a6a3523..bd9e466cd7 100644 --- a/ApplicationCode/ProjectDataModel/RimFileWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimFileWellPath.cpp @@ -33,7 +33,7 @@ RimFileWellPath::RimFileWellPath() m_surveyType.uiCapability()->setUiReadOnly( true ); 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 ); CAF_PDM_InitField( &m_wellPathIndexInFile, "WellPathNumberInFile", -1, "Well Number in File", "", "", "" ); m_wellPathIndexInFile.uiCapability()->setUiReadOnly( true ); @@ -49,7 +49,7 @@ RimFileWellPath::~RimFileWellPath() {} //-------------------------------------------------------------------------------------------------- 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 ) { - if ( caf::Utils::fileExists( m_filepath() ) ) + if ( caf::Utils::fileExists( m_filepath().path() ) ) { - RifWellPathImporter::WellData wellData = wellPathImporter->readWellData( m_filepath(), m_wellPathIndexInFile() ); - RifWellPathImporter::WellMetaData wellMetaData = wellPathImporter->readWellMetaData( m_filepath(), + RifWellPathImporter::WellData wellData = wellPathImporter->readWellData( m_filepath().path(), + m_wellPathIndexInFile() ); + + RifWellPathImporter::WellMetaData wellMetaData = wellPathImporter->readWellMetaData( m_filepath().path(), m_wellPathIndexInFile() ); // General well info @@ -132,7 +134,7 @@ bool RimFileWellPath::readWellPathFile( QString* errorMessage, RifWellPathImport } 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; } } @@ -152,7 +154,7 @@ QString RimFileWellPath::getCacheDirectoryPath() //-------------------------------------------------------------------------------------------------- QString RimFileWellPath::getCacheFileName() { - if ( m_filepath().isEmpty() ) + if ( m_filepath().path().isEmpty() ) { return ""; } @@ -161,7 +163,7 @@ QString RimFileWellPath::getCacheFileName() // Make the path correct related to the possibly new project filename QString newCacheDirPath = getCacheDirectoryPath(); - QFileInfo oldCacheFile( m_filepath ); + QFileInfo oldCacheFile( m_filepath().path() ); cacheFileName = newCacheDirPath + "/" + oldCacheFile.fileName(); @@ -179,7 +181,7 @@ void RimFileWellPath::setupBeforeSave() return; } - if ( m_filepath().isEmpty() ) + if ( m_filepath().path().isEmpty() ) { return; } @@ -189,12 +191,12 @@ void RimFileWellPath::setupBeforeSave() QString newCacheFileName = getCacheFileName(); // 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 ); if ( prevFileInfo.absoluteFilePath().compare( currentFileInfo.absoluteFilePath() ) != 0 ) { - QFile::copy( m_filepath, newCacheFileName ); + QFile::copy( m_filepath().path(), newCacheFileName ); m_filepath = newCacheFileName; } @@ -214,7 +216,7 @@ bool RimFileWellPath::isStoredInCache() //-------------------------------------------------------------------------------------------------- void RimFileWellPath::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) { - RimWellPath::updateFilePathsFromProjectPath( newProjectPath, oldProjectPath ); + // RimWellPath::updateFilePathsFromProjectPath( newProjectPath, oldProjectPath ); if ( isStoredInCache() ) { @@ -225,8 +227,8 @@ void RimFileWellPath::updateFilePathsFromProjectPath( const QString& newProjectP m_filepath = newCacheFileName; } } - else - { - m_filepath = RimTools::relocateFile( m_filepath(), newProjectPath, oldProjectPath, nullptr, nullptr ); - } + // else + // { + // m_filepath = RimTools::relocateFile( m_filepath(), newProjectPath, oldProjectPath, nullptr, nullptr ); + // } } diff --git a/ApplicationCode/ProjectDataModel/RimFileWellPath.h b/ApplicationCode/ProjectDataModel/RimFileWellPath.h index 3dfdcbc3a3..77e91051f8 100644 --- a/ApplicationCode/ProjectDataModel/RimFileWellPath.h +++ b/ApplicationCode/ProjectDataModel/RimFileWellPath.h @@ -45,8 +45,8 @@ private: void setupBeforeSave() override; - caf::PdmField m_filepath; - caf::PdmField m_wellPathIndexInFile; // -1 means none. + caf::PdmField m_filepath; + caf::PdmField m_wellPathIndexInFile; // -1 means none. caf::PdmField id; caf::PdmField sourceSystem; diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.cpp b/ApplicationCode/ProjectDataModel/RimWellPath.cpp index ec658990f9..5293359909 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPath.cpp @@ -118,7 +118,7 @@ RimWellPath::RimWellPath() CAF_PDM_InitField( &m_formationKeyInFile, "WellPathFormationKeyInFile", QString( "" ), "Key in File", "", "", "" ); 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 ); 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 ) { - { - bool foundFile = false; - std::vector searchedPaths; - - QString fileNameCandidate = RimTools::relocateFile( m_wellPathFormationFilePath, - newProjectPath, - oldProjectPath, - &foundFile, - &searchedPaths ); - if ( foundFile ) - { - m_wellPathFormationFilePath = fileNameCandidate; - } - } + //{ + // bool foundFile = false; + // std::vector searchedPaths; + // + // QString fileNameCandidate = RimTools::relocateFile( m_wellPathFormationFilePath, + // newProjectPath, + // oldProjectPath, + // &foundFile, + // &searchedPaths ); + // if ( foundFile ) + // { + // m_wellPathFormationFilePath = fileNameCandidate; + // } + //} } //-------------------------------------------------------------------------------------------------- @@ -738,14 +738,14 @@ void RimWellPath::setFormationsGeometry( cvf::ref wellPat bool RimWellPath::readWellPathFormationsFile( QString* errorMessage, RifWellPathFormationsImporter* wellPathFormationsImporter ) { - if ( m_wellPathFormationFilePath().isEmpty() ) + if ( m_wellPathFormationFilePath().path().isEmpty() ) { 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() ); if ( m_name().isEmpty() ) { @@ -755,7 +755,8 @@ bool RimWellPath::readWellPathFormationsFile( QString* err } 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; } } @@ -766,20 +767,21 @@ bool RimWellPath::readWellPathFormationsFile( QString* err bool RimWellPath::reloadWellPathFormationsFile( QString* errorMessage, RifWellPathFormationsImporter* wellPathFormationsImporter ) { - if ( m_wellPathFormationFilePath().isEmpty() ) + if ( m_wellPathFormationFilePath().path().isEmpty() ) { 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() ); return true; } 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; } } diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.h b/ApplicationCode/ProjectDataModel/RimWellPath.h index 1a978ce839..0694a60724 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.h +++ b/ApplicationCode/ProjectDataModel/RimWellPath.h @@ -25,6 +25,7 @@ #include "RimWellPathComponentInterface.h" #include "cafAppEnum.h" +#include "cafFilePath.h" #include "cafPdmChildField.h" #include "cafPdmField.h" #include "cafPdmObject.h" @@ -158,8 +159,8 @@ private: caf::PdmField m_unitSystem; - caf::PdmField m_wellPathFormationFilePath; - caf::PdmField m_formationKeyInFile; + caf::PdmField m_wellPathFormationFilePath; + caf::PdmField m_formationKeyInFile; caf::PdmField m_showWellPath; caf::PdmField m_showWellPathLabel; From 7f1ccc0169e201fba33aabc5274c144d419823a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 11 Dec 2019 08:30:32 +0100 Subject: [PATCH 08/19] #5147 RimStimPlanFractureTemplate::m_stimPlanFileName -> FilePath --- .../Completions/RimStimPlanFractureTemplate.cpp | 10 +++++----- .../Completions/RimStimPlanFractureTemplate.h | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index 8ff591e4a9..a75a90ae11 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -69,7 +69,7 @@ RimStimPlanFractureTemplate::RimStimPlanFractureTemplate() 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()); 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, 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; - m_stimPlanFractureDefinitionData = RifStimPlanXmlReader::readStimPlanXMLFile( m_stimPlanFileName(), + m_stimPlanFractureDefinitionData = RifStimPlanXmlReader::readStimPlanXMLFile( m_stimPlanFileName().path(), m_conductivityScaleFactor(), m_halfLengthScaleFactor(), m_heightScaleFactor(), diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h index 177955f77b..abf76478e7 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h @@ -56,8 +56,8 @@ public: void loadDataAndUpdate() override; void setDefaultsBasedOnXMLfile(); - void setFileName( const QString& fileName ); - const QString& fileName(); + void setFileName( const QString& fileName ); + QString fileName(); void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ); @@ -130,7 +130,7 @@ private: caf::PdmField m_wellPathDepthAtFracture; caf::PdmField m_borderPolygonResultName; - caf::PdmField m_stimPlanFileName; + caf::PdmField m_stimPlanFileName; cvf::ref m_stimPlanFractureDefinitionData; cvf::ref m_fractureGrid; bool m_readError; From b1942e0844b9c3de28f02600698cb25da4fcf341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 11 Dec 2019 08:38:31 +0100 Subject: [PATCH 09/19] #5147 RimWellLogFile::m_fileName ->FilePath --- .../ProjectDataModel/RimWellLogFile.cpp | 22 +++++++++---------- .../ProjectDataModel/RimWellLogFile.h | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimWellLogFile.cpp b/ApplicationCode/ProjectDataModel/RimWellLogFile.cpp index c6258567d8..6690c9d9ef 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogFile.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogFile.cpp @@ -151,9 +151,9 @@ bool RimWellLogFile::readFile( QString* errorMessage ) 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; return false; @@ -242,15 +242,15 @@ bool RimWellLogFile::hasFlowData() const //-------------------------------------------------------------------------------------------------- void RimWellLogFile::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) { - bool foundFile = false; - std::vector searchedPaths; - - QString fileNameCandidate = - RimTools::relocateFile( m_fileName(), newProjectPath, oldProjectPath, &foundFile, &searchedPaths ); - if ( foundFile ) - { - m_fileName = fileNameCandidate; - } + // bool foundFile = false; + // std::vector searchedPaths; + // + // QString fileNameCandidate = + // RimTools::relocateFile( m_fileName(), newProjectPath, oldProjectPath, &foundFile, &searchedPaths ); + // if ( foundFile ) + // { + // m_fileName = fileNameCandidate; + // } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellLogFile.h b/ApplicationCode/ProjectDataModel/RimWellLogFile.h index 32ab9bd89d..1b2273d44b 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogFile.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogFile.h @@ -51,7 +51,7 @@ public: void setFileName( const QString& fileName ); QString fileName() const { - return m_fileName; + return m_fileName().path(); } QString name() const { @@ -109,7 +109,7 @@ private: private: cvf::ref m_wellLogDataFile; caf::PdmField m_wellName; - caf::PdmField m_fileName; + caf::PdmField m_fileName; caf::PdmField m_name; caf::PdmField m_date; bool m_lasFileHasValidDate; From 37b32c4e8a8da7ea0639f2438309eeb4e70b36e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 11 Dec 2019 09:31:13 +0100 Subject: [PATCH 10/19] #5147 RimFormationNames::m_formationNamesFileName -> FilePath --- .../ProjectDataModel/RimFormationNames.cpp | 24 ++++++++++--------- .../ProjectDataModel/RimFormationNames.h | 8 +++---- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimFormationNames.cpp b/ApplicationCode/ProjectDataModel/RimFormationNames.cpp index 85daa8fb14..3b025ebd45 100644 --- a/ApplicationCode/ProjectDataModel/RimFormationNames.cpp +++ b/ApplicationCode/ProjectDataModel/RimFormationNames.cpp @@ -42,7 +42,7 @@ RimFormationNames::RimFormationNames() { 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() ); } @@ -92,9 +92,9 @@ void RimFormationNames::setFileName( const QString& fileName ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const QString& RimFormationNames::fileName() +QString RimFormationNames::fileName() { - return m_formationNamesFileName(); + return m_formationNamesFileName().path(); } //-------------------------------------------------------------------------------------------------- @@ -102,7 +102,7 @@ const QString& RimFormationNames::fileName() //-------------------------------------------------------------------------------------------------- QString RimFormationNames::fileNameWoPath() { - QFileInfo fnameFileInfo( m_formationNamesFileName() ); + QFileInfo fnameFileInfo( m_formationNamesFileName().path() ); return fnameFileInfo.fileName(); } @@ -142,18 +142,19 @@ void RimFormationNames::updateConnectedViews() //-------------------------------------------------------------------------------------------------- void RimFormationNames::readFormationNamesFile( QString* errorMessage ) { - QFile dataFile( m_formationNamesFileName() ); + QFile dataFile( m_formationNamesFileName().path() ); 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; } m_formationNamesData = new RigFormationNames; QTextStream stream( &dataFile ); - QFileInfo fileInfo( m_formationNamesFileName() ); + QFileInfo fileInfo( m_formationNamesFileName().path() ); if ( fileInfo.fileName() == RimFormationNames::layerZoneTableFileName() ) { @@ -170,8 +171,8 @@ void RimFormationNames::readFormationNamesFile( QString* errorMessage ) //-------------------------------------------------------------------------------------------------- void RimFormationNames::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) { - m_formationNamesFileName = - RimTools::relocateFile( m_formationNamesFileName(), newProjectPath, oldProjectPath, nullptr, nullptr ); + // m_formationNamesFileName = + // RimTools::relocateFile( m_formationNamesFileName(), newProjectPath, oldProjectPath, nullptr, nullptr ); } //-------------------------------------------------------------------------------------------------- @@ -297,8 +298,9 @@ void RimFormationNames::readFmuFormationNameFile( QTextStream& stream, QString* if ( lineStream.status() != QTextStream::Ok ) { - *errorMessage = - QString( "Failed to parse line %1 of '%2'" ).arg( lineNumber ).arg( m_formationNamesFileName() ); + *errorMessage = QString( "Failed to parse line %1 of '%2'" ) + .arg( lineNumber ) + .arg( m_formationNamesFileName().path() ); return; } diff --git a/ApplicationCode/ProjectDataModel/RimFormationNames.h b/ApplicationCode/ProjectDataModel/RimFormationNames.h index a46b697cdd..6a3467f314 100644 --- a/ApplicationCode/ProjectDataModel/RimFormationNames.h +++ b/ApplicationCode/ProjectDataModel/RimFormationNames.h @@ -36,9 +36,9 @@ public: RimFormationNames(); ~RimFormationNames() override; - void setFileName( const QString& fileName ); - const QString& fileName(); - QString fileNameWoPath(); + void setFileName( const QString& fileName ); + QString fileName(); + QString fileNameWoPath(); RigFormationNames* formationNamesData() { @@ -63,7 +63,7 @@ private: void readFmuFormationNameFile( QTextStream& stream, QString* errorMessage ); private: - caf::PdmField m_formationNamesFileName; + caf::PdmField m_formationNamesFileName; cvf::ref m_formationNamesData; }; From 0f9b667c5572949260487e6709d42c07d17b9582 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 11 Dec 2019 10:27:49 +0100 Subject: [PATCH 11/19] Guard against missing well path geometry data --- .../RicExportFractureCompletionsImpl.cpp | 2 +- .../RicFishbonesTransmissibilityCalculationFeatureImp.cpp | 4 ++-- .../RicWellPathExportCompletionDataFeatureImpl.cpp | 7 ++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp index 0113ffb71b..db7ece485f 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp @@ -218,7 +218,7 @@ std::vector RicExportFractureCompletionsImpl::generateCompdat { std::vector fractureCompletions; - if ( !caseToApply || !caseToApply->eclipseCaseData() ) + if ( !caseToApply || !caseToApply->eclipseCaseData() || !wellPathGeometry ) { return fractureCompletions; } diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp index 6194bfa901..79492c60eb 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp @@ -87,7 +87,7 @@ std::vector { std::vector completionData; - if ( !wellPath || !wellPath->completions() ) + if ( !wellPath || !wellPath->completions() || !wellPath->wellPathGeometry() ) { return completionData; } @@ -197,7 +197,7 @@ void RicFishbonesTransmissibilityCalculationFeatureImp::findFishboneLateralsWell const RimWellPath* wellPath, const RicExportCompletionDataSettingsUi& settings ) { - if ( !wellPath ) return; + if ( !wellPath || !wellPath->wellPathGeometry() ) return; // Generate data const RigEclipseCaseData* caseData = settings.caseToApply()->eclipseCaseData(); diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index 7ee44b1482..6933eea044 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -1168,7 +1168,12 @@ std::vector RicWellPathExportCompletionDataFeatureImpl::gener RiaEclipseUnitTools::UnitSystem unitSystem = settings.caseToApply->eclipseCaseData()->unitsType(); std::vector completionData; - const RigActiveCellInfo* activeCellInfo = settings.caseToApply->eclipseCaseData()->activeCellInfo( + if ( !wellPath || !wellPath->wellPathGeometry() ) + { + return completionData; + } + + const RigActiveCellInfo* activeCellInfo = settings.caseToApply->eclipseCaseData()->activeCellInfo( RiaDefines::MATRIX_MODEL ); if ( wellPath->perforationIntervalCollection()->isChecked() ) From 298b40d6ef396e076f90a6625578c5589914225b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 11 Dec 2019 11:39:02 +0100 Subject: [PATCH 12/19] Refactor: Centralized generation of path to storage of wellpaths from SSIHUB --- .../RicWellPathsImportSsihubFeature.cpp | 6 ++++-- .../Commands/SsiHubImportCommands/RimWellPathImport.cpp | 4 ++-- ApplicationCode/ProjectDataModel/RimFileWellPath.h | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/Commands/SsiHubImportCommands/RicWellPathsImportSsihubFeature.cpp b/ApplicationCode/Commands/SsiHubImportCommands/RicWellPathsImportSsihubFeature.cpp index a78806612b..f163211443 100644 --- a/ApplicationCode/Commands/SsiHubImportCommands/RicWellPathsImportSsihubFeature.cpp +++ b/ApplicationCode/Commands/SsiHubImportCommands/RicWellPathsImportSsihubFeature.cpp @@ -21,9 +21,12 @@ #include "RiaApplication.h" #include "RiaPreferences.h" + +#include "RimFileWellPath.h" #include "RimProject.h" #include "RimTools.h" #include "RimWellPathImport.h" + #include "RiuMainWindow.h" #include "RiuWellImportWizard.h" @@ -82,8 +85,7 @@ void RicWellPathsImportSsihubFeature::onActionTriggered( bool isChecked ) // Update the UTM bounding box from the reservoir app->project()->computeUtmAreaOfInterest(); - QString wellPathsFolderPath = RimTools::getCacheRootDirectoryPathFromProject(); - wellPathsFolderPath += "_wellpaths"; + QString wellPathsFolderPath = RimFileWellPath::getCacheDirectoryPath(); QDir::root().mkpath( wellPathsFolderPath ); if ( !app->project()->wellPathImport() ) return; diff --git a/ApplicationCode/Commands/SsiHubImportCommands/RimWellPathImport.cpp b/ApplicationCode/Commands/SsiHubImportCommands/RimWellPathImport.cpp index ca04ee0e9f..c20a7f0ff4 100644 --- a/ApplicationCode/Commands/SsiHubImportCommands/RimWellPathImport.cpp +++ b/ApplicationCode/Commands/SsiHubImportCommands/RimWellPathImport.cpp @@ -18,6 +18,7 @@ #include "RimWellPathImport.h" +#include "RimFileWellPath.h" #include "RimOilFieldEntry.h" #include "RimOilRegionEntry.h" #include "RimTools.h" @@ -224,8 +225,7 @@ RimWellPathImport::~RimWellPathImport() //-------------------------------------------------------------------------------------------------- void RimWellPathImport::updateFilePaths() { - QString wellPathsFolderPath = RimTools::getCacheRootDirectoryPathFromProject(); - wellPathsFolderPath += "_wellpaths"; + QString wellPathsFolderPath = RimFileWellPath::getCacheDirectoryPath(); for ( size_t regionIdx = 0; regionIdx < this->regions.size(); regionIdx++ ) { diff --git a/ApplicationCode/ProjectDataModel/RimFileWellPath.h b/ApplicationCode/ProjectDataModel/RimFileWellPath.h index 77e91051f8..00e36d5320 100644 --- a/ApplicationCode/ProjectDataModel/RimFileWellPath.h +++ b/ApplicationCode/ProjectDataModel/RimFileWellPath.h @@ -32,6 +32,7 @@ public: int wellPathIndexInFile() const; // -1 means none. void setWellPathIndexInFile( int index ); void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) override; + static QString getCacheDirectoryPath(); private: QString surveyType() @@ -41,7 +42,6 @@ private: void setSurveyType( QString surveyType ); bool isStoredInCache(); QString getCacheFileName(); - QString getCacheDirectoryPath(); void setupBeforeSave() override; From e4eea67a4eaa917cc35d073f45b5a6c4c2cef1fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 12 Dec 2019 16:09:20 +0100 Subject: [PATCH 13/19] Fix error in cafFilePath QVariant isEqual operator --- .../cafPdmCore/cafInternalPdmValueFieldSpecializations.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafInternalPdmValueFieldSpecializations.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafInternalPdmValueFieldSpecializations.h index 11930802b0..2079ee837c 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafInternalPdmValueFieldSpecializations.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafInternalPdmValueFieldSpecializations.h @@ -162,7 +162,7 @@ public: static bool isEqual(const QVariant& variantValue, const QVariant& variantValue2) { - return variantValue.value() == variantValue2.value(); + return variantValue.toString() == variantValue2.toString(); } }; From 1c6c82af852631662710eb32cadb31001f2ceebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 12 Dec 2019 16:15:24 +0100 Subject: [PATCH 14/19] #5147 Fix RimFileWellPath::setupBeforeSave addressing the filePath Needs to copy the cached wellpaths on save. Split the cached filePath and the uncached filePath to only list the external well paths in the global path list, and to be able to copy the cached files on save. --- ...cWellPathFractureTextReportFeatureImpl.cpp | 2 +- .../ProjectDataModel/RimFileWellPath.cpp | 68 ++++++++++++++----- .../ProjectDataModel/RimFileWellPath.h | 7 +- .../ProjectDataModel/RimWellLogFile.cpp | 4 +- .../RimWellPathCollection.cpp | 10 +-- 5 files changed, 62 insertions(+), 29 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathFractureTextReportFeatureImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathFractureTextReportFeatureImpl.cpp index c2cc5193d7..1d74f807fc 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathFractureTextReportFeatureImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathFractureTextReportFeatureImpl.cpp @@ -254,7 +254,7 @@ QString RicWellPathFractureTextReportFeatureImpl::createWellFileLocationText( co if ( fileWellPath ) { formatter.add( wellPath->name() ); - formatter.add( fileWellPath->filepath() ); + formatter.add( fileWellPath->filePath() ); formatter.rowCompleted(); } } diff --git a/ApplicationCode/ProjectDataModel/RimFileWellPath.cpp b/ApplicationCode/ProjectDataModel/RimFileWellPath.cpp index bd9e466cd7..408b74252d 100644 --- a/ApplicationCode/ProjectDataModel/RimFileWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimFileWellPath.cpp @@ -33,8 +33,11 @@ RimFileWellPath::RimFileWellPath() m_surveyType.uiCapability()->setUiReadOnly( true ); m_surveyType.xmlCapability()->disableIO(); - CAF_PDM_InitFieldNoDefault( &m_filepath, "WellPathFilepath", "File Path", "", "", "" ); - m_filepath.uiCapability()->setUiReadOnly( true ); + CAF_PDM_InitFieldNoDefault( &m_filePath, "WellPathFilepath", "File Path", "", "", "" ); + m_filePath.uiCapability()->setUiReadOnly( true ); + CAF_PDM_InitFieldNoDefault( &m_filePathInCache, "WellPathFilePathInCache", "File Name", "", "", "" ); + m_filePathInCache.uiCapability()->setUiReadOnly( true ); + CAF_PDM_InitField( &m_wellPathIndexInFile, "WellPathNumberInFile", -1, "Well Number in File", "", "", "" ); m_wellPathIndexInFile.uiCapability()->setUiReadOnly( true ); } @@ -47,9 +50,16 @@ RimFileWellPath::~RimFileWellPath() {} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimFileWellPath::filepath() const +QString RimFileWellPath::filePath() const { - return m_filepath().path(); + 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 ) { - m_filepath = path; + m_filePath = path; } //-------------------------------------------------------------------------------------------------- @@ -96,7 +106,16 @@ void RimFileWellPath::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering RimWellPath::defineUiOrdering( uiConfigName, uiOrdering ); 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 ); if ( !id().isEmpty() ) uiOrdering.insertBeforeItem( m_datumElevation.uiCapability(), &id ); @@ -112,12 +131,12 @@ void RimFileWellPath::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering //-------------------------------------------------------------------------------------------------- bool RimFileWellPath::readWellPathFile( QString* errorMessage, RifWellPathImporter* wellPathImporter ) { - if ( caf::Utils::fileExists( m_filepath().path() ) ) + if ( caf::Utils::fileExists( this->filePath() ) ) { - RifWellPathImporter::WellData wellData = wellPathImporter->readWellData( m_filepath().path(), + RifWellPathImporter::WellData wellData = wellPathImporter->readWellData( this->filePath(), m_wellPathIndexInFile() ); - RifWellPathImporter::WellMetaData wellMetaData = wellPathImporter->readWellMetaData( m_filepath().path(), + RifWellPathImporter::WellMetaData wellMetaData = wellPathImporter->readWellMetaData( this->filePath(), m_wellPathIndexInFile() ); // General well info @@ -130,11 +149,22 @@ bool RimFileWellPath::readWellPathFile( QString* errorMessage, RifWellPathImport updateDate = wellMetaData.m_updateDate.toString( "d MMMM yyyy" ); setWellPathGeometry( wellData.m_wellPathGeometry.p() ); + + // Now that the data is read, we know if this is an SSIHUB wellpath that needs to be stored in the + // cache folder along with the project file. If it is, move the pathfile reference to the m_filePathInCache + // in order to avoid it being handled as an externalFilePath by the RimProject class + + if ( isStoredInCache() && !m_filePath().path().isEmpty() ) + { + m_filePathInCache = m_filePath().path(); + m_filePath = QString( "" ); + } + return true; } else { - if ( errorMessage ) ( *errorMessage ) = "Could not find the well path file: " + m_filepath().path(); + if ( errorMessage ) ( *errorMessage ) = "Could not find the well path file: " + this->filePath(); return false; } } @@ -154,7 +184,7 @@ QString RimFileWellPath::getCacheDirectoryPath() //-------------------------------------------------------------------------------------------------- QString RimFileWellPath::getCacheFileName() { - if ( m_filepath().path().isEmpty() ) + if ( m_filePathInCache().isEmpty() ) { return ""; } @@ -162,8 +192,9 @@ QString RimFileWellPath::getCacheFileName() QString cacheFileName; // Make the path correct related to the possibly new project filename + QString newCacheDirPath = getCacheDirectoryPath(); - QFileInfo oldCacheFile( m_filepath().path() ); + QFileInfo oldCacheFile( m_filePathInCache() ); cacheFileName = newCacheDirPath + "/" + oldCacheFile.fileName(); @@ -175,13 +206,14 @@ QString RimFileWellPath::getCacheFileName() //-------------------------------------------------------------------------------------------------- void RimFileWellPath::setupBeforeSave() { + // Copy the possibly "cached" SSIHUB wellpath, stored in the folder along the project file // SSIHUB is the only source for populating Id, use text in this field to decide if the cache file must be copied to new project cache location if ( !isStoredInCache() ) { return; } - if ( m_filepath().path().isEmpty() ) + if ( m_filePathInCache().isEmpty() ) { return; } @@ -191,21 +223,21 @@ void RimFileWellPath::setupBeforeSave() QString newCacheFileName = getCacheFileName(); // Use QFileInfo to get same string representation to avoid issues with mix of forward and backward slashes - QFileInfo prevFileInfo( m_filepath().path() ); + QFileInfo prevFileInfo( m_filePathInCache() ); QFileInfo currentFileInfo( newCacheFileName ); if ( prevFileInfo.absoluteFilePath().compare( currentFileInfo.absoluteFilePath() ) != 0 ) { - QFile::copy( m_filepath().path(), 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 return !id().isEmpty(); @@ -224,7 +256,7 @@ void RimFileWellPath::updateFilePathsFromProjectPath( const QString& newProjectP if ( caf::Utils::fileExists( newCacheFileName ) ) { - m_filepath = newCacheFileName; + m_filePathInCache = newCacheFileName; } } // else diff --git a/ApplicationCode/ProjectDataModel/RimFileWellPath.h b/ApplicationCode/ProjectDataModel/RimFileWellPath.h index 00e36d5320..62b52bc730 100644 --- a/ApplicationCode/ProjectDataModel/RimFileWellPath.h +++ b/ApplicationCode/ProjectDataModel/RimFileWellPath.h @@ -26,7 +26,7 @@ public: RimFileWellPath(); ~RimFileWellPath() override; - QString filepath() const; + QString filePath() const; void setFilepath( const QString& path ); bool readWellPathFile( QString* errorMessage, RifWellPathImporter* wellPathImporter ); int wellPathIndexInFile() const; // -1 means none. @@ -40,12 +40,13 @@ private: return m_surveyType; } void setSurveyType( QString surveyType ); - bool isStoredInCache(); + bool isStoredInCache() const; QString getCacheFileName(); void setupBeforeSave() override; - caf::PdmField m_filepath; + caf::PdmField m_filePath; + caf::PdmField m_filePathInCache; // Used for SSIHUB imported well paths caf::PdmField m_wellPathIndexInFile; // -1 means none. caf::PdmField id; diff --git a/ApplicationCode/ProjectDataModel/RimWellLogFile.cpp b/ApplicationCode/ProjectDataModel/RimWellLogFile.cpp index 6690c9d9ef..e9481ea864 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogFile.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogFile.cpp @@ -191,7 +191,7 @@ bool RimWellLogFile::readFile( QString* errorMessage ) this->firstAncestorOrThisOfType( wellPath ); if ( wellPath ) { - if ( wellPath->filepath().isEmpty() ) // Has dummy wellpath + if ( wellPath->filePath().isEmpty() ) // Has dummy wellpath { wellPath->setName( m_wellName ); } @@ -244,7 +244,7 @@ void RimWellLogFile::updateFilePathsFromProjectPath( const QString& newProjectPa { // bool foundFile = false; // std::vector searchedPaths; - // + // // QString fileNameCandidate = // RimTools::relocateFile( m_fileName(), newProjectPath, oldProjectPath, &foundFile, &searchedPaths ); // if ( foundFile ) diff --git a/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp b/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp index 15d27099b8..579aee84de 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp @@ -148,7 +148,7 @@ void RimWellPathCollection::loadDataAndUpdate() RimModeledWellPath* mWPath = dynamic_cast( wellPaths[wpIdx] ); if ( fWPath ) { - if ( !fWPath->filepath().isEmpty() ) + if ( !fWPath->filePath().isEmpty() ) { QString errorMessage; if ( !fWPath->readWellPathFile( &errorMessage, m_wellPathImporter ) ) @@ -221,7 +221,7 @@ std::vector RimWellPathCollection::addWellPaths( QStringList fileP f1.setFileName( filePath ); QString s1 = f1.fileName(); QFile f2; - f2.setFileName( fWPath->filepath() ); + f2.setFileName( fWPath->filePath() ); QString s2 = f2.fileName(); if ( s1 == s2 ) { @@ -285,7 +285,7 @@ void RimWellPathCollection::readAndAddWellPaths( std::vector& RimFileWellPath* existingWellPath = dynamic_cast( tryFindMatchingWellPath( wellPath->name() ) ); if ( existingWellPath ) { - existingWellPath->setFilepath( wellPath->filepath() ); + existingWellPath->setFilepath( wellPath->filePath() ); existingWellPath->setWellPathIndexInFile( wellPath->wellPathIndexInFile() ); existingWellPath->readWellPathFile( nullptr, m_wellPathImporter ); @@ -596,7 +596,7 @@ void RimWellPathCollection::removeWellPath( RimWellPath* wellPath ) for ( size_t i = 0; i < wellPaths.size(); i++ ) { RimFileWellPath* fWPath = dynamic_cast( wellPaths[i] ); - if ( fWPath && fWPath->filepath() == fileWellPath->filepath() ) + if ( fWPath && fWPath->filePath() == fileWellPath->filePath() ) { isFilePathUsed = true; break; @@ -607,7 +607,7 @@ void RimWellPathCollection::removeWellPath( RimWellPath* wellPath ) { // One file can have multiple well paths // If no other well paths are referencing the filepath, remove cached data from the file reader - m_wellPathImporter->removeFilePath( fileWellPath->filepath() ); + m_wellPathImporter->removeFilePath( fileWellPath->filePath() ); } } updateAllRequiredEditors(); From b7db416652acb52d784e898def489c239b08fbc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 12 Dec 2019 16:19:50 +0100 Subject: [PATCH 15/19] #5147 Avoid using RimFormationNames::m_formationNamesFileName in initAfterRead The path is not valid during initAfterRead Traversal --- ApplicationCode/ProjectDataModel/RimFormationNames.cpp | 3 ++- ApplicationCode/ProjectDataModel/RimFormationNames.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimFormationNames.cpp b/ApplicationCode/ProjectDataModel/RimFormationNames.cpp index 3b025ebd45..9fb2105f38 100644 --- a/ApplicationCode/ProjectDataModel/RimFormationNames.cpp +++ b/ApplicationCode/ProjectDataModel/RimFormationNames.cpp @@ -68,13 +68,14 @@ void RimFormationNames::fieldChangedByUi( const caf::PdmFieldHandle* changedFiel { QMessageBox::warning( nullptr, "Formation Names", errorMessage ); } + updateConnectedViews(); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimFormationNames::initAfterRead() +void RimFormationNames::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/ ) { updateUiTreeName(); } diff --git a/ApplicationCode/ProjectDataModel/RimFormationNames.h b/ApplicationCode/ProjectDataModel/RimFormationNames.h index 6a3467f314..b4398a7d07 100644 --- a/ApplicationCode/ProjectDataModel/RimFormationNames.h +++ b/ApplicationCode/ProjectDataModel/RimFormationNames.h @@ -55,7 +55,8 @@ protected: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; - void initAfterRead() override; + + virtual void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; private: void updateUiTreeName(); From 0bd9ef925af7f9f9cd5e91dc520cbf216d38988d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 13 Dec 2019 10:27:38 +0100 Subject: [PATCH 16/19] #5147 RimEclipseResultCase::m_sourSimFileName ->FilePath --- .../ProjectDataModel/RimEclipseResultCase.cpp | 10 +++++----- .../ProjectDataModel/RimEclipseResultCase.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp index 123bf2a0eb..d2c8c94281 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp @@ -94,7 +94,7 @@ RimEclipseResultCase::RimEclipseResultCase() m_flipYAxis.xmlCapability()->setIOWritable( 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() ); #ifndef USE_HDF5 m_sourSimFileName.uiCapability()->setUiHidden( true ); @@ -225,10 +225,10 @@ bool RimEclipseResultCase::importGridAndResultMetaData( bool showTimeStepFilter m_flowDiagSolutions.push_back( new RimFlowDiagSolution() ); } - if ( !m_sourSimFileName().isEmpty() ) + if ( !m_sourSimFileName().path().isEmpty() ) { RifReaderEclipseOutput* outReader = dynamic_cast( readerInterface.p() ); - outReader->setHdf5FileName( m_sourSimFileName() ); + outReader->setHdf5FileName( m_sourSimFileName().path() ); } RiaApplication* app = RiaApplication::instance(); @@ -323,7 +323,7 @@ void RimEclipseResultCase::loadAndUpdateSourSimData() { if ( !results( RiaDefines::MATRIX_MODEL ) ) return; - results( RiaDefines::MATRIX_MODEL )->setHdf5Filename( m_sourSimFileName ); + results( RiaDefines::MATRIX_MODEL )->setHdf5Filename( m_sourSimFileName().path() ); if ( !hasSourSimFile() ) { @@ -587,7 +587,7 @@ void RimEclipseResultCase::setSourSimFileName( const QString& fileName ) //-------------------------------------------------------------------------------------------------- bool RimEclipseResultCase::hasSourSimFile() { - return !m_sourSimFileName().isEmpty(); + return !m_sourSimFileName().path().isEmpty(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultCase.h b/ApplicationCode/ProjectDataModel/RimEclipseResultCase.h index 699c6f4745..27c2d2531a 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultCase.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultCase.h @@ -102,7 +102,7 @@ private: caf::PdmField caseFileName; caf::PdmProxyValueField m_unitSystem; caf::PdmChildArrayField m_flowDiagSolutions; - caf::PdmField m_sourSimFileName; + caf::PdmField m_sourSimFileName; // Obsolete field caf::PdmField caseDirectory; From 7f393f5ad80d434854b2b7141a0fd56a404c7f2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 17 Dec 2019 13:24:37 +0100 Subject: [PATCH 17/19] #5147 Use "PathId_000" as base for the path ids --- ApplicationCode/ProjectDataModel/RimProject.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 043455864d..a2ff851fef 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -1494,7 +1494,8 @@ public: private: QString createUnusedId() { - QString pathIdentifier = PATHIDCHAR + pathIdBaseString + QString::number( m_nextValidIdNumber ) + PATHIDCHAR; + QString numberString = QString( "%1" ).arg( (uint)m_nextValidIdNumber, 3, 10, QChar( '0' ) ); + QString pathIdentifier = PATHIDCHAR + pathIdBaseString + numberString + PATHIDCHAR; m_nextValidIdNumber++; return pathIdentifier; } From 2ca3345a20d678fbabed053f32f91ed220e16296 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 17 Dec 2019 13:27:02 +0100 Subject: [PATCH 18/19] Add save() as a command to the python interface Fix export_snapshot issue --- .../GrpcInterface/GrpcProtos/Commands.proto | 6 ++++++ ApplicationCode/GrpcInterface/Python/rips/project.py | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/GrpcInterface/GrpcProtos/Commands.proto b/ApplicationCode/GrpcInterface/GrpcProtos/Commands.proto index f986749a4e..2a0902a430 100644 --- a/ApplicationCode/GrpcInterface/GrpcProtos/Commands.proto +++ b/ApplicationCode/GrpcInterface/GrpcProtos/Commands.proto @@ -323,6 +323,11 @@ message ExportContourMapToTextRequest int32 viewId = 5; } +message SaveProjectRequest +{ + string filePath = 1; +} + /* CommandParams handles both command name and parameters in one. * The message type and content is used as parameters and * the name of the variable is used to find the command name. */ @@ -372,6 +377,7 @@ message CommandParams ExportWellLogPlotDataRequest exportWellLogPlotData = 36; SetWindowSizeParams setPlotWindowSize = 37; ExportContourMapToTextRequest exportContourMapToText = 38; + SaveProjectRequest saveProject = 39; } } diff --git a/ApplicationCode/GrpcInterface/Python/rips/project.py b/ApplicationCode/GrpcInterface/Python/rips/project.py index 09ae3b0e44..0a1b06b8f4 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/project.py +++ b/ApplicationCode/GrpcInterface/Python/rips/project.py @@ -36,6 +36,14 @@ class Project(PdmObject): """ self._execute_command(openProject=Cmd.FilePathRequest(path=path)) 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): """Close the current project (and open new blank project)""" @@ -223,7 +231,7 @@ class Project(PdmObject): """ return self._execute_command( exportSnapshots=Cmd.ExportSnapshotsRequest( - type=snapshot_type, prefix=prefix, caseId=-1)) + type=snapshot_type, prefix=prefix, caseId=-1, viewId=-1 )) def export_well_paths(self, well_paths=None, md_step_size=5.0): """ Export a set of well paths From 1575705835cd4855167f88a2cbdc3b578354c2bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 18 Dec 2019 09:05:39 +0100 Subject: [PATCH 19/19] Fix whitespace difference --- ApplicationCode/GrpcInterface/Python/rips/project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/GrpcInterface/Python/rips/project.py b/ApplicationCode/GrpcInterface/Python/rips/project.py index 0a1b06b8f4..63bdf3038d 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/project.py +++ b/ApplicationCode/GrpcInterface/Python/rips/project.py @@ -231,7 +231,7 @@ class Project(PdmObject): """ return self._execute_command( exportSnapshots=Cmd.ExportSnapshotsRequest( - type=snapshot_type, prefix=prefix, caseId=-1, viewId=-1 )) + type=snapshot_type, prefix=prefix, caseId=-1, viewId=-1)) def export_well_paths(self, well_paths=None, md_step_size=5.0): """ Export a set of well paths