mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
SSIHUB: Update file paths for and well path cache
Consolidated cache creation in RimTools
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user