mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-01 03:37:15 -06:00
SSIHUB: Update file paths for and well path cache
Consolidated cache creation in RimTools
This commit is contained in:
parent
5772767f79
commit
40092b0d62
@ -43,6 +43,7 @@ ${CEE_CURRENT_LIST_DIR}RimReservoirCellResultsCacher.h
|
||||
${CEE_CURRENT_LIST_DIR}RimStatisticsCaseEvaluator.h
|
||||
${CEE_CURRENT_LIST_DIR}RimMimeData.h
|
||||
${CEE_CURRENT_LIST_DIR}RimCommandObject.h
|
||||
${CEE_CURRENT_LIST_DIR}RimTools.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@ -84,6 +85,7 @@ ${CEE_CURRENT_LIST_DIR}RimReservoirCellResultsCacher.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimStatisticsCaseEvaluator.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimMimeData.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimCommandObject.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimTools.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
@ -344,6 +344,16 @@ void RimProject::setProjectFileNameAndUpdateDependencies(const QString& fileName
|
||||
{
|
||||
cases[i]->updateFilePathsFromProjectPath(newProjectPath, oldProjectPath);
|
||||
}
|
||||
|
||||
// Update path to well path file cache
|
||||
for (size_t oilFieldIdx = 0; oilFieldIdx < oilFields().size(); oilFieldIdx++)
|
||||
{
|
||||
RimOilField* oilField = oilFields[oilFieldIdx];
|
||||
if (oilField == NULL || oilField->wellPathCollection == NULL) continue;
|
||||
oilField->wellPathCollection->updateFilePathsFromProjectPath();
|
||||
}
|
||||
|
||||
wellPathImport->updateFilePaths();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include "RimWellPathCollection.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimAnalysisModels.h"
|
||||
#include "RimTools.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimReservoirCellResultsStorage, "ReservoirCellResultStorage");
|
||||
|
||||
@ -211,11 +212,8 @@ QString RimReservoirCellResultsStorage::getValidCacheFileName()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimReservoirCellResultsStorage::getCacheDirectoryPath()
|
||||
{
|
||||
QString cacheDirPath;
|
||||
QString projectFileName = RiaApplication::instance()->project()->fileName();
|
||||
QFileInfo fileInfo(projectFileName);
|
||||
cacheDirPath = fileInfo.canonicalPath();
|
||||
cacheDirPath += "/" + fileInfo.completeBaseName() + "_cache";
|
||||
QString cacheDirPath = RimTools::getCacheRootDirectoryPathFromProject();
|
||||
cacheDirPath += "_cache";
|
||||
return cacheDirPath;
|
||||
}
|
||||
|
||||
|
62
ApplicationCode/ProjectDataModel/RimTools.cpp
Normal file
62
ApplicationCode/ProjectDataModel/RimTools.cpp
Normal file
@ -0,0 +1,62 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaStdInclude.h"
|
||||
|
||||
#include "RimTools.h"
|
||||
|
||||
#include "RivWellPathCollectionPartMgr.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimCase.h"
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
#include "RimScriptCollection.h"
|
||||
#include "RimReservoirView.h"
|
||||
#include "RimReservoirCellResultsCacher.h"
|
||||
#include "RimCaseCollection.h"
|
||||
#include "RimResultSlot.h"
|
||||
#include "RimCellEdgeResultSlot.h"
|
||||
#include "RimCellPropertyFilterCollection.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
#include "RivWellPathPartMgr.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimAnalysisModels.h"
|
||||
#include "RiaApplication.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimTools::getCacheRootDirectoryPathFromProject()
|
||||
{
|
||||
if (!RiaApplication::instance()->project())
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString projectFileName = RiaApplication::instance()->project()->fileName();
|
||||
|
||||
QString cacheRootFolderPath;
|
||||
QFileInfo fileInfo(projectFileName);
|
||||
cacheRootFolderPath = fileInfo.canonicalPath();
|
||||
cacheRootFolderPath += "/" + fileInfo.completeBaseName();
|
||||
|
||||
return cacheRootFolderPath;
|
||||
}
|
27
ApplicationCode/ProjectDataModel/RimTools.h
Normal file
27
ApplicationCode/ProjectDataModel/RimTools.h
Normal file
@ -0,0 +1,27 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
class RimProject;
|
||||
|
||||
class RimTools
|
||||
{
|
||||
public:
|
||||
static QString getCacheRootDirectoryPathFromProject();
|
||||
};
|
@ -45,6 +45,7 @@
|
||||
|
||||
#include <fstream>
|
||||
#include <limits>
|
||||
#include "RimTools.h"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimWellPath, "WellPath");
|
||||
@ -268,11 +269,8 @@ void RimWellPath::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiO
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimWellPath::getCacheDirectoryPath()
|
||||
{
|
||||
QString cacheDirPath;
|
||||
QString projectFileName = RiaApplication::instance()->project()->fileName();
|
||||
QFileInfo fileInfo(projectFileName);
|
||||
cacheDirPath = fileInfo.canonicalPath();
|
||||
cacheDirPath += "/" + fileInfo.completeBaseName() + "_wellpaths";
|
||||
QString cacheDirPath = RimTools::getCacheRootDirectoryPathFromProject();
|
||||
cacheDirPath += "_wellpaths";
|
||||
return cacheDirPath;
|
||||
}
|
||||
|
||||
@ -298,7 +296,7 @@ QString RimWellPath::getCacheFileName()
|
||||
void RimWellPath::setupBeforeSave()
|
||||
{
|
||||
// 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 (id().isEmpty())
|
||||
if (!isStoredInCache())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -318,3 +316,26 @@ void RimWellPath::setupBeforeSave()
|
||||
filepath = newCacheFileName;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimWellPath::isStoredInCache()
|
||||
{
|
||||
// SSIHUB is the only source for populating Id, use text in this field to decide if the cache file must be copied to new project cache location
|
||||
return !id().isEmpty();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellPath::updateFilePathsFromProjectPath()
|
||||
{
|
||||
QString newCacheFileName = getCacheFileName();
|
||||
|
||||
if (QFile::exists(newCacheFileName))
|
||||
{
|
||||
filepath = newCacheFileName;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,9 @@ public:
|
||||
RivWellPathPartMgr* partMgr();
|
||||
|
||||
void readWellPathFile();
|
||||
|
||||
void updateFilePathsFromProjectPath();
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@ -76,11 +78,11 @@ private:
|
||||
|
||||
virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering );
|
||||
|
||||
bool isStoredInCache();
|
||||
QString getCacheFileName();
|
||||
QString getCacheDirectoryPath();
|
||||
|
||||
virtual void setupBeforeSave();
|
||||
|
||||
caf::PdmField<QString> id;
|
||||
caf::PdmField<QString> sourceSystem;
|
||||
caf::PdmField<QString> utmZone;
|
||||
|
@ -235,6 +235,17 @@ void RimWellPathCollection::scheduleGeometryRegenAndRedrawViews()
|
||||
if (m_project) m_project->createDisplayModelAndRedrawAllViews();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellPathCollection::updateFilePathsFromProjectPath()
|
||||
{
|
||||
for (size_t wellPathIdx = 0; wellPathIdx < wellPaths.size(); wellPathIdx++)
|
||||
{
|
||||
wellPaths[wellPathIdx]->updateFilePathsFromProjectPath();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -74,7 +74,8 @@ public:
|
||||
virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue );
|
||||
|
||||
void scheduleGeometryRegenAndRedrawViews();
|
||||
|
||||
void updateFilePathsFromProjectPath();
|
||||
|
||||
private:
|
||||
virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering );
|
||||
virtual caf::PdmFieldHandle* objectToggleField();
|
||||
|
@ -61,6 +61,7 @@
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RiuWellImportWizard.h"
|
||||
#include "RimCalcScript.h"
|
||||
#include "RimTools.h"
|
||||
#include "RiaRegressionTest.h"
|
||||
|
||||
|
||||
@ -1646,16 +1647,9 @@ void RiuMainWindow::slotImportWellPathsFromSSIHub()
|
||||
// Update the UTM bounding box from the reservoir
|
||||
app->project()->computeUtmAreaOfInterest();
|
||||
|
||||
QString wellPathsFolderPath;
|
||||
QString projectFileName = app->project()->fileName();
|
||||
QFileInfo fileInfo(projectFileName);
|
||||
wellPathsFolderPath = fileInfo.canonicalPath();
|
||||
QString wellPathFolderName = fileInfo.completeBaseName() + "_wellpaths";
|
||||
|
||||
QDir projFolder(wellPathsFolderPath);
|
||||
projFolder.mkdir(wellPathFolderName);
|
||||
|
||||
wellPathsFolderPath += "/" + wellPathFolderName;
|
||||
QString wellPathsFolderPath = RimTools::getCacheRootDirectoryPathFromProject();
|
||||
wellPathsFolderPath += "_wellpaths";
|
||||
QDir::root().mkpath(wellPathsFolderPath);
|
||||
|
||||
RimWellPathImport* copyOfWellPathImport = dynamic_cast<RimWellPathImport*>(app->project()->wellPathImport->deepCopy());
|
||||
RiuWellImportWizard wellImportwizard(app->preferences()->ssihubAddress, wellPathsFolderPath, copyOfWellPathImport, this);
|
||||
|
@ -17,8 +17,14 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RimWellPathImport.h"
|
||||
#include "RimTools.h"
|
||||
#include "RimWellPath.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
|
||||
#include "cafPdmUiTreeViewEditor.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
|
||||
namespace caf {
|
||||
|
||||
template<>
|
||||
@ -209,5 +215,37 @@ RimWellPathImport::~RimWellPathImport()
|
||||
regions.deleteAllChildObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellPathImport::updateFilePaths()
|
||||
{
|
||||
QString wellPathsFolderPath = RimTools::getCacheRootDirectoryPathFromProject();
|
||||
wellPathsFolderPath += "_wellpaths";
|
||||
|
||||
for (size_t regionIdx = 0; regionIdx < this->regions.size(); regionIdx++)
|
||||
{
|
||||
for (size_t fIdx = 0; fIdx < this->regions[regionIdx]->fields.size(); fIdx++)
|
||||
{
|
||||
RimOilFieldEntry* oilField = this->regions[regionIdx]->fields[fIdx];
|
||||
|
||||
QFileInfo fi(oilField->wellsFilePath);
|
||||
|
||||
QString newWellsFilePath = wellPathsFolderPath + "/" + fi.fileName();
|
||||
oilField->wellsFilePath = newWellsFilePath;
|
||||
|
||||
for (size_t wIdx = 0; wIdx < oilField->wells.size(); wIdx++)
|
||||
{
|
||||
RimWellPathEntry* rimWellPathEntry = oilField->wells[wIdx];
|
||||
|
||||
QFileInfo fiWell(rimWellPathEntry->wellPathFilePath);
|
||||
|
||||
QString newFilePath = wellPathsFolderPath + "/" + fiWell.fileName();
|
||||
rimWellPathEntry->wellPathFilePath = newFilePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -62,7 +62,7 @@ public:
|
||||
|
||||
void updateFieldVisibility();
|
||||
|
||||
|
||||
void updateFilePaths();
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user