SSIHUB: Update file paths for and well path cache

Consolidated cache creation in RimTools
This commit is contained in:
Magne Sjaastad
2013-10-24 09:50:16 +02:00
parent 5772767f79
commit 40092b0d62
12 changed files with 191 additions and 25 deletions

View File

@@ -43,6 +43,7 @@ ${CEE_CURRENT_LIST_DIR}RimReservoirCellResultsCacher.h
${CEE_CURRENT_LIST_DIR}RimStatisticsCaseEvaluator.h ${CEE_CURRENT_LIST_DIR}RimStatisticsCaseEvaluator.h
${CEE_CURRENT_LIST_DIR}RimMimeData.h ${CEE_CURRENT_LIST_DIR}RimMimeData.h
${CEE_CURRENT_LIST_DIR}RimCommandObject.h ${CEE_CURRENT_LIST_DIR}RimCommandObject.h
${CEE_CURRENT_LIST_DIR}RimTools.h
) )
set (SOURCE_GROUP_SOURCE_FILES 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}RimStatisticsCaseEvaluator.cpp
${CEE_CURRENT_LIST_DIR}RimMimeData.cpp ${CEE_CURRENT_LIST_DIR}RimMimeData.cpp
${CEE_CURRENT_LIST_DIR}RimCommandObject.cpp ${CEE_CURRENT_LIST_DIR}RimCommandObject.cpp
${CEE_CURRENT_LIST_DIR}RimTools.cpp
) )
list(APPEND CODE_HEADER_FILES list(APPEND CODE_HEADER_FILES

View File

@@ -344,6 +344,16 @@ void RimProject::setProjectFileNameAndUpdateDependencies(const QString& fileName
{ {
cases[i]->updateFilePathsFromProjectPath(newProjectPath, oldProjectPath); 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();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -47,6 +47,7 @@
#include "RimWellPathCollection.h" #include "RimWellPathCollection.h"
#include "RimOilField.h" #include "RimOilField.h"
#include "RimAnalysisModels.h" #include "RimAnalysisModels.h"
#include "RimTools.h"
CAF_PDM_SOURCE_INIT(RimReservoirCellResultsStorage, "ReservoirCellResultStorage"); CAF_PDM_SOURCE_INIT(RimReservoirCellResultsStorage, "ReservoirCellResultStorage");
@@ -211,11 +212,8 @@ QString RimReservoirCellResultsStorage::getValidCacheFileName()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QString RimReservoirCellResultsStorage::getCacheDirectoryPath() QString RimReservoirCellResultsStorage::getCacheDirectoryPath()
{ {
QString cacheDirPath; QString cacheDirPath = RimTools::getCacheRootDirectoryPathFromProject();
QString projectFileName = RiaApplication::instance()->project()->fileName(); cacheDirPath += "_cache";
QFileInfo fileInfo(projectFileName);
cacheDirPath = fileInfo.canonicalPath();
cacheDirPath += "/" + fileInfo.completeBaseName() + "_cache";
return cacheDirPath; return cacheDirPath;
} }

View 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;
}

View 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();
};

View File

@@ -45,6 +45,7 @@
#include <fstream> #include <fstream>
#include <limits> #include <limits>
#include "RimTools.h"
CAF_PDM_SOURCE_INIT(RimWellPath, "WellPath"); CAF_PDM_SOURCE_INIT(RimWellPath, "WellPath");
@@ -268,11 +269,8 @@ void RimWellPath::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiO
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QString RimWellPath::getCacheDirectoryPath() QString RimWellPath::getCacheDirectoryPath()
{ {
QString cacheDirPath; QString cacheDirPath = RimTools::getCacheRootDirectoryPathFromProject();
QString projectFileName = RiaApplication::instance()->project()->fileName(); cacheDirPath += "_wellpaths";
QFileInfo fileInfo(projectFileName);
cacheDirPath = fileInfo.canonicalPath();
cacheDirPath += "/" + fileInfo.completeBaseName() + "_wellpaths";
return cacheDirPath; return cacheDirPath;
} }
@@ -298,7 +296,7 @@ QString RimWellPath::getCacheFileName()
void RimWellPath::setupBeforeSave() 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 // 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; return;
} }
@@ -318,3 +316,26 @@ void RimWellPath::setupBeforeSave()
filepath = newCacheFileName; 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;
}
}

View File

@@ -64,7 +64,9 @@ public:
RivWellPathPartMgr* partMgr(); RivWellPathPartMgr* partMgr();
void readWellPathFile(); void readWellPathFile();
void updateFilePathsFromProjectPath();
private: private:
@@ -76,11 +78,11 @@ private:
virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering );
bool isStoredInCache();
QString getCacheFileName(); QString getCacheFileName();
QString getCacheDirectoryPath(); QString getCacheDirectoryPath();
virtual void setupBeforeSave(); virtual void setupBeforeSave();
caf::PdmField<QString> id; caf::PdmField<QString> id;
caf::PdmField<QString> sourceSystem; caf::PdmField<QString> sourceSystem;
caf::PdmField<QString> utmZone; caf::PdmField<QString> utmZone;

View File

@@ -235,6 +235,17 @@ void RimWellPathCollection::scheduleGeometryRegenAndRedrawViews()
if (m_project) m_project->createDisplayModelAndRedrawAllViews(); if (m_project) m_project->createDisplayModelAndRedrawAllViews();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathCollection::updateFilePathsFromProjectPath()
{
for (size_t wellPathIdx = 0; wellPathIdx < wellPaths.size(); wellPathIdx++)
{
wellPaths[wellPathIdx]->updateFilePathsFromProjectPath();
}
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -74,7 +74,8 @@ public:
virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ); virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue );
void scheduleGeometryRegenAndRedrawViews(); void scheduleGeometryRegenAndRedrawViews();
void updateFilePathsFromProjectPath();
private: private:
virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering );
virtual caf::PdmFieldHandle* objectToggleField(); virtual caf::PdmFieldHandle* objectToggleField();

View File

@@ -61,6 +61,7 @@
#include "Rim3dOverlayInfoConfig.h" #include "Rim3dOverlayInfoConfig.h"
#include "RiuWellImportWizard.h" #include "RiuWellImportWizard.h"
#include "RimCalcScript.h" #include "RimCalcScript.h"
#include "RimTools.h"
#include "RiaRegressionTest.h" #include "RiaRegressionTest.h"
@@ -1646,16 +1647,9 @@ void RiuMainWindow::slotImportWellPathsFromSSIHub()
// Update the UTM bounding box from the reservoir // Update the UTM bounding box from the reservoir
app->project()->computeUtmAreaOfInterest(); app->project()->computeUtmAreaOfInterest();
QString wellPathsFolderPath; QString wellPathsFolderPath = RimTools::getCacheRootDirectoryPathFromProject();
QString projectFileName = app->project()->fileName(); wellPathsFolderPath += "_wellpaths";
QFileInfo fileInfo(projectFileName); QDir::root().mkpath(wellPathsFolderPath);
wellPathsFolderPath = fileInfo.canonicalPath();
QString wellPathFolderName = fileInfo.completeBaseName() + "_wellpaths";
QDir projFolder(wellPathsFolderPath);
projFolder.mkdir(wellPathFolderName);
wellPathsFolderPath += "/" + wellPathFolderName;
RimWellPathImport* copyOfWellPathImport = dynamic_cast<RimWellPathImport*>(app->project()->wellPathImport->deepCopy()); RimWellPathImport* copyOfWellPathImport = dynamic_cast<RimWellPathImport*>(app->project()->wellPathImport->deepCopy());
RiuWellImportWizard wellImportwizard(app->preferences()->ssihubAddress, wellPathsFolderPath, copyOfWellPathImport, this); RiuWellImportWizard wellImportwizard(app->preferences()->ssihubAddress, wellPathsFolderPath, copyOfWellPathImport, this);

View File

@@ -17,8 +17,14 @@
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
#include "RimWellPathImport.h" #include "RimWellPathImport.h"
#include "RimTools.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "cafPdmUiTreeViewEditor.h" #include "cafPdmUiTreeViewEditor.h"
#include <QFileInfo>
namespace caf { namespace caf {
template<> template<>
@@ -209,5 +215,37 @@ RimWellPathImport::~RimWellPathImport()
regions.deleteAllChildObjects(); 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;
}
}
}
}

View File

@@ -62,7 +62,7 @@ public:
void updateFieldVisibility(); void updateFieldVisibility();
void updateFilePaths();
}; };