mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2609 RimFileWellPath in separate file
This commit is contained in:
parent
ce41eef365
commit
2ea84bdb63
@ -24,6 +24,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimCellEdgeColors.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimSimWellInView.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimSimWellInViewCollection.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellPath.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimFileWellPath.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellPathCollection.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellPathTarget.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimScriptCollection.h
|
||||
@ -134,6 +135,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimCellEdgeColors.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimSimWellInView.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimSimWellInViewCollection.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellPath.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimFileWellPath.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellPathCollection.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellPathTarget.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimScriptCollection.cpp
|
||||
|
244
ApplicationCode/ProjectDataModel/RimFileWellPath.cpp
Normal file
244
ApplicationCode/ProjectDataModel/RimFileWellPath.cpp
Normal file
@ -0,0 +1,244 @@
|
||||
#include "RimFileWellPath.h"
|
||||
#include "cafUtils.h"
|
||||
#include "RifWellPathImporter.h"
|
||||
#include "RimTools.h"
|
||||
#include "QFileInfo"
|
||||
#include "QDir"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimFileWellPath, "WellPath");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimFileWellPath::RimFileWellPath()
|
||||
{
|
||||
CAF_PDM_InitFieldNoDefault(&id, "WellPathId", "Id", "", "", "");
|
||||
id.uiCapability()->setUiReadOnly(true);
|
||||
id.xmlCapability()->setIOWritable(false);
|
||||
id.xmlCapability()->setIOReadable(false);
|
||||
CAF_PDM_InitFieldNoDefault(&sourceSystem, "SourceSystem", "Source System", "", "", "");
|
||||
sourceSystem.uiCapability()->setUiReadOnly(true);
|
||||
sourceSystem.xmlCapability()->setIOWritable(false);
|
||||
sourceSystem.xmlCapability()->setIOReadable(false);
|
||||
CAF_PDM_InitFieldNoDefault(&utmZone, "UTMZone", "UTM Zone", "", "", "");
|
||||
utmZone.uiCapability()->setUiReadOnly(true);
|
||||
utmZone.xmlCapability()->setIOWritable(false);
|
||||
utmZone.xmlCapability()->setIOReadable(false);
|
||||
CAF_PDM_InitFieldNoDefault(&updateDate, "WellPathUpdateDate", "Update Date", "", "", "");
|
||||
updateDate.uiCapability()->setUiReadOnly(true);
|
||||
updateDate.xmlCapability()->setIOWritable(false);
|
||||
updateDate.xmlCapability()->setIOReadable(false);
|
||||
CAF_PDM_InitFieldNoDefault(&updateUser, "WellPathUpdateUser", "Update User", "", "", "");
|
||||
updateUser.uiCapability()->setUiReadOnly(true);
|
||||
updateUser.xmlCapability()->setIOWritable(false);
|
||||
updateUser.xmlCapability()->setIOReadable(false);
|
||||
CAF_PDM_InitFieldNoDefault(&m_surveyType, "WellPathSurveyType", "Survey Type", "", "", "");
|
||||
m_surveyType.uiCapability()->setUiReadOnly(true);
|
||||
m_surveyType.xmlCapability()->setIOWritable(false);
|
||||
m_surveyType.xmlCapability()->setIOReadable(false);
|
||||
|
||||
CAF_PDM_InitField(&m_filepath, "WellPathFilepath", QString(""), "File Path", "", "", "");
|
||||
m_filepath.uiCapability()->setUiReadOnly(true);
|
||||
CAF_PDM_InitField(&m_wellPathIndexInFile, "WellPathNumberInFile", -1, "Well Number in File", "", "", "");
|
||||
m_wellPathIndexInFile.uiCapability()->setUiReadOnly(true);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimFileWellPath::~RimFileWellPath()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimFileWellPath::filepath() const
|
||||
{
|
||||
return m_filepath();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFileWellPath::setFilepath(const QString& path)
|
||||
{
|
||||
m_filepath = path;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RimFileWellPath::wellPathIndexInFile() const
|
||||
{
|
||||
return m_wellPathIndexInFile();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFileWellPath::setWellPathIndexInFile(int index)
|
||||
{
|
||||
m_wellPathIndexInFile = index ;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFileWellPath::setSurveyType(QString surveyType)
|
||||
{
|
||||
m_surveyType = surveyType;
|
||||
if (m_surveyType == "PLAN")
|
||||
setWellPathColor(cvf::Color3f(0.999f, 0.333f, 0.0f));
|
||||
else if (m_surveyType == "PROTOTYPE")
|
||||
setWellPathColor(cvf::Color3f(0.0f, 0.333f, 0.999f));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFileWellPath::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
||||
{
|
||||
RimWellPath::defineUiOrdering(uiConfigName, uiOrdering);
|
||||
|
||||
caf::PdmUiGroup* fileInfoGroup = uiOrdering.createGroupBeforeGroup("Simulation Well", "File");
|
||||
fileInfoGroup->add(&m_filepath);
|
||||
fileInfoGroup->add(&m_wellPathIndexInFile);
|
||||
|
||||
if ( !id().isEmpty() ) uiOrdering.insertBeforeItem(m_datumElevation.uiCapability(), &id);
|
||||
if ( !sourceSystem().isEmpty() ) uiOrdering.insertBeforeItem(m_datumElevation.uiCapability(), &sourceSystem);
|
||||
if ( !utmZone().isEmpty() ) uiOrdering.insertBeforeItem(m_datumElevation.uiCapability(), &utmZone);
|
||||
if ( !updateDate().isEmpty() ) uiOrdering.insertBeforeItem(m_datumElevation.uiCapability(), &updateDate);
|
||||
if ( !updateUser().isEmpty() ) uiOrdering.insertBeforeItem(m_datumElevation.uiCapability(), &updateUser);
|
||||
if ( !m_surveyType().isEmpty() ) uiOrdering.insertBeforeItem(m_datumElevation.uiCapability(), &m_surveyType);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Read JSON or ascii file containing well path data
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimFileWellPath::readWellPathFile(QString* errorMessage, RifWellPathImporter* wellPathImporter)
|
||||
{
|
||||
if (caf::Utils::fileExists(m_filepath()))
|
||||
{
|
||||
RifWellPathImporter::WellData wellData = wellPathImporter->readWellData(m_filepath(), m_wellPathIndexInFile());
|
||||
RifWellPathImporter::WellMetaData wellMetaData = wellPathImporter->readWellMetaData(m_filepath(), m_wellPathIndexInFile());
|
||||
// General well info
|
||||
|
||||
setName(wellData.m_name);
|
||||
id = wellMetaData.m_id;
|
||||
sourceSystem = wellMetaData.m_sourceSystem;
|
||||
utmZone = wellMetaData.m_utmZone;
|
||||
updateUser = wellMetaData.m_updateUser;
|
||||
setSurveyType(wellMetaData.m_surveyType);
|
||||
updateDate = wellMetaData.m_updateDate.toString("d MMMM yyyy");
|
||||
|
||||
setWellPathGeometry(wellData.m_wellPathGeometry.p());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (errorMessage) (*errorMessage) = "Could not find the well path file: " + m_filepath();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimFileWellPath::getCacheDirectoryPath()
|
||||
{
|
||||
QString cacheDirPath = RimTools::getCacheRootDirectoryPathFromProject();
|
||||
cacheDirPath += "_wellpaths";
|
||||
return cacheDirPath;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimFileWellPath::getCacheFileName()
|
||||
{
|
||||
if (m_filepath().isEmpty())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
QString cacheFileName;
|
||||
|
||||
// Make the path correct related to the possibly new project filename
|
||||
QString newCacheDirPath = getCacheDirectoryPath();
|
||||
QFileInfo oldCacheFile(m_filepath);
|
||||
|
||||
|
||||
cacheFileName = newCacheDirPath + "/" + oldCacheFile.fileName();
|
||||
|
||||
return cacheFileName;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFileWellPath::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 (!isStoredInCache())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_filepath().isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QDir::root().mkpath(getCacheDirectoryPath());
|
||||
|
||||
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 currentFileInfo(newCacheFileName);
|
||||
|
||||
if (prevFileInfo.absoluteFilePath().compare(currentFileInfo.absoluteFilePath()) != 0)
|
||||
{
|
||||
QFile::copy(m_filepath, newCacheFileName);
|
||||
|
||||
m_filepath = newCacheFileName;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimFileWellPath::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 RimFileWellPath::updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath)
|
||||
{
|
||||
RimWellPath::updateFilePathsFromProjectPath(newProjectPath, oldProjectPath);
|
||||
|
||||
if (isStoredInCache())
|
||||
{
|
||||
QString newCacheFileName = getCacheFileName();
|
||||
|
||||
if (caf::Utils::fileExists(newCacheFileName))
|
||||
{
|
||||
m_filepath = newCacheFileName;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_filepath = RimTools::relocateFile(m_filepath(), newProjectPath, oldProjectPath, nullptr, nullptr);
|
||||
}
|
||||
}
|
||||
|
59
ApplicationCode/ProjectDataModel/RimFileWellPath.h
Normal file
59
ApplicationCode/ProjectDataModel/RimFileWellPath.h
Normal file
@ -0,0 +1,59 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018- Equinor ASA
|
||||
//
|
||||
// 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
|
||||
#include "RimWellPath.h"
|
||||
|
||||
class RimFileWellPath : public RimWellPath
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
public:
|
||||
|
||||
RimFileWellPath();
|
||||
~RimFileWellPath();
|
||||
|
||||
QString filepath() const;
|
||||
void setFilepath(const QString& path);
|
||||
bool readWellPathFile(QString * errorMessage, RifWellPathImporter* wellPathImporter);
|
||||
int wellPathIndexInFile() const; // -1 means none.
|
||||
void setWellPathIndexInFile(int index);
|
||||
void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath) override;
|
||||
|
||||
private:
|
||||
QString surveyType() { return m_surveyType; }
|
||||
void setSurveyType(QString surveyType);
|
||||
bool isStoredInCache();
|
||||
QString getCacheFileName();
|
||||
QString getCacheDirectoryPath();
|
||||
|
||||
virtual void setupBeforeSave() override;
|
||||
|
||||
caf::PdmField<QString> m_filepath;
|
||||
caf::PdmField<int> m_wellPathIndexInFile; // -1 means none.
|
||||
|
||||
caf::PdmField<QString> id;
|
||||
caf::PdmField<QString> sourceSystem;
|
||||
caf::PdmField<QString> utmZone;
|
||||
caf::PdmField<QString> updateDate;
|
||||
caf::PdmField<QString> updateUser;
|
||||
caf::PdmField<QString> m_surveyType;
|
||||
|
||||
|
||||
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
|
||||
};
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
#include "RimWellLogFile.h"
|
||||
#include "RimWellLogFileChannel.h"
|
||||
#include "RimWellPath.h"
|
||||
#include "RimFileWellPath.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
#include "RimTools.h"
|
||||
//#include "RimWellPltPlot.h"
|
||||
|
@ -158,37 +158,6 @@ caf::PdmFieldHandle* RimWellPath::userDescriptionField()
|
||||
return &m_name;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFileWellPath::setSurveyType(QString surveyType)
|
||||
{
|
||||
m_surveyType = surveyType;
|
||||
if (m_surveyType == "PLAN")
|
||||
setWellPathColor(cvf::Color3f(0.999f, 0.333f, 0.0f));
|
||||
else if (m_surveyType == "PROTOTYPE")
|
||||
setWellPathColor(cvf::Color3f(0.0f, 0.333f, 0.999f));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFileWellPath::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
||||
{
|
||||
RimWellPath::defineUiOrdering(uiConfigName, uiOrdering);
|
||||
|
||||
caf::PdmUiGroup* fileInfoGroup = uiOrdering.createGroupBeforeGroup("Simulation Well", "File");
|
||||
fileInfoGroup->add(&m_filepath);
|
||||
fileInfoGroup->add(&m_wellPathIndexInFile);
|
||||
|
||||
if ( !id().isEmpty() ) uiOrdering.insertBeforeItem(m_datumElevation.uiCapability(), &id);
|
||||
if ( !sourceSystem().isEmpty() ) uiOrdering.insertBeforeItem(m_datumElevation.uiCapability(), &sourceSystem);
|
||||
if ( !utmZone().isEmpty() ) uiOrdering.insertBeforeItem(m_datumElevation.uiCapability(), &utmZone);
|
||||
if ( !updateDate().isEmpty() ) uiOrdering.insertBeforeItem(m_datumElevation.uiCapability(), &updateDate);
|
||||
if ( !updateUser().isEmpty() ) uiOrdering.insertBeforeItem(m_datumElevation.uiCapability(), &updateUser);
|
||||
if ( !m_surveyType().isEmpty() ) uiOrdering.insertBeforeItem(m_datumElevation.uiCapability(), &m_surveyType);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -402,87 +371,6 @@ std::vector<RimWellLogFile*> RimWellPath::wellLogFiles() const
|
||||
{
|
||||
return std::vector<RimWellLogFile*>(m_wellLogFiles.begin(), m_wellLogFiles.end());
|
||||
}
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimFileWellPath, "WellPath");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimFileWellPath::RimFileWellPath()
|
||||
{
|
||||
CAF_PDM_InitFieldNoDefault(&id, "WellPathId", "Id", "", "", "");
|
||||
id.uiCapability()->setUiReadOnly(true);
|
||||
id.xmlCapability()->setIOWritable(false);
|
||||
id.xmlCapability()->setIOReadable(false);
|
||||
CAF_PDM_InitFieldNoDefault(&sourceSystem, "SourceSystem", "Source System", "", "", "");
|
||||
sourceSystem.uiCapability()->setUiReadOnly(true);
|
||||
sourceSystem.xmlCapability()->setIOWritable(false);
|
||||
sourceSystem.xmlCapability()->setIOReadable(false);
|
||||
CAF_PDM_InitFieldNoDefault(&utmZone, "UTMZone", "UTM Zone", "", "", "");
|
||||
utmZone.uiCapability()->setUiReadOnly(true);
|
||||
utmZone.xmlCapability()->setIOWritable(false);
|
||||
utmZone.xmlCapability()->setIOReadable(false);
|
||||
CAF_PDM_InitFieldNoDefault(&updateDate, "WellPathUpdateDate", "Update Date", "", "", "");
|
||||
updateDate.uiCapability()->setUiReadOnly(true);
|
||||
updateDate.xmlCapability()->setIOWritable(false);
|
||||
updateDate.xmlCapability()->setIOReadable(false);
|
||||
CAF_PDM_InitFieldNoDefault(&updateUser, "WellPathUpdateUser", "Update User", "", "", "");
|
||||
updateUser.uiCapability()->setUiReadOnly(true);
|
||||
updateUser.xmlCapability()->setIOWritable(false);
|
||||
updateUser.xmlCapability()->setIOReadable(false);
|
||||
CAF_PDM_InitFieldNoDefault(&m_surveyType, "WellPathSurveyType", "Survey Type", "", "", "");
|
||||
m_surveyType.uiCapability()->setUiReadOnly(true);
|
||||
m_surveyType.xmlCapability()->setIOWritable(false);
|
||||
m_surveyType.xmlCapability()->setIOReadable(false);
|
||||
|
||||
CAF_PDM_InitField(&m_filepath, "WellPathFilepath", QString(""), "File Path", "", "", "");
|
||||
m_filepath.uiCapability()->setUiReadOnly(true);
|
||||
CAF_PDM_InitField(&m_wellPathIndexInFile, "WellPathNumberInFile", -1, "Well Number in File", "", "", "");
|
||||
m_wellPathIndexInFile.uiCapability()->setUiReadOnly(true);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimFileWellPath::~RimFileWellPath()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimFileWellPath::filepath() const
|
||||
{
|
||||
return m_filepath();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFileWellPath::setFilepath(const QString& path)
|
||||
{
|
||||
m_filepath = path;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RimFileWellPath::wellPathIndexInFile() const
|
||||
{
|
||||
return m_wellPathIndexInFile();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFileWellPath::setWellPathIndexInFile(int index)
|
||||
{
|
||||
m_wellPathIndexInFile = index ;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -523,35 +411,6 @@ caf::PdmFieldHandle* RimWellPath::objectToggleField()
|
||||
return &m_showWellPath;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Read JSON or ascii file containing well path data
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimFileWellPath::readWellPathFile(QString* errorMessage, RifWellPathImporter* wellPathImporter)
|
||||
{
|
||||
if (caf::Utils::fileExists(m_filepath()))
|
||||
{
|
||||
RifWellPathImporter::WellData wellData = wellPathImporter->readWellData(m_filepath(), m_wellPathIndexInFile());
|
||||
RifWellPathImporter::WellMetaData wellMetaData = wellPathImporter->readWellMetaData(m_filepath(), m_wellPathIndexInFile());
|
||||
// General well info
|
||||
|
||||
setName(wellData.m_name);
|
||||
id = wellMetaData.m_id;
|
||||
sourceSystem = wellMetaData.m_sourceSystem;
|
||||
utmZone = wellMetaData.m_utmZone;
|
||||
updateUser = wellMetaData.m_updateUser;
|
||||
setSurveyType(wellMetaData.m_surveyType);
|
||||
updateDate = wellMetaData.m_updateDate.toString("d MMMM yyyy");
|
||||
|
||||
setWellPathGeometry(wellData.m_wellPathGeometry.p());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (errorMessage) (*errorMessage) = "Could not find the well path file: " + m_filepath();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -627,70 +486,6 @@ void RimWellPath::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, Q
|
||||
uiTreeOrdering.skipRemainingChildren(true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimFileWellPath::getCacheDirectoryPath()
|
||||
{
|
||||
QString cacheDirPath = RimTools::getCacheRootDirectoryPathFromProject();
|
||||
cacheDirPath += "_wellpaths";
|
||||
return cacheDirPath;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimFileWellPath::getCacheFileName()
|
||||
{
|
||||
if (m_filepath().isEmpty())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
QString cacheFileName;
|
||||
|
||||
// Make the path correct related to the possibly new project filename
|
||||
QString newCacheDirPath = getCacheDirectoryPath();
|
||||
QFileInfo oldCacheFile(m_filepath);
|
||||
|
||||
|
||||
cacheFileName = newCacheDirPath + "/" + oldCacheFile.fileName();
|
||||
|
||||
return cacheFileName;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFileWellPath::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 (!isStoredInCache())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_filepath().isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QDir::root().mkpath(getCacheDirectoryPath());
|
||||
|
||||
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 currentFileInfo(newCacheFileName);
|
||||
|
||||
if (prevFileInfo.absoluteFilePath().compare(currentFileInfo.absoluteFilePath()) != 0)
|
||||
{
|
||||
QFile::copy(m_filepath, newCacheFileName);
|
||||
|
||||
m_filepath = newCacheFileName;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -703,37 +498,6 @@ size_t RimWellPath::simulationWellBranchCount(const QString& simWellName)
|
||||
return branches.size();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimFileWellPath::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 RimFileWellPath::updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath)
|
||||
{
|
||||
RimWellPath::updateFilePathsFromProjectPath(newProjectPath, oldProjectPath);
|
||||
|
||||
if (isStoredInCache())
|
||||
{
|
||||
QString newCacheFileName = getCacheFileName();
|
||||
|
||||
if (caf::Utils::fileExists(newCacheFileName))
|
||||
{
|
||||
m_filepath = newCacheFileName;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_filepath = RimTools::relocateFile(m_filepath(), newProjectPath, oldProjectPath, nullptr, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -171,42 +171,3 @@ private:
|
||||
|
||||
caf::PdmChildField<RimWellLogFile*> m_wellLogFile_OBSOLETE;
|
||||
};
|
||||
|
||||
class RimFileWellPath : public RimWellPath
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
public:
|
||||
|
||||
RimFileWellPath();
|
||||
~RimFileWellPath();
|
||||
|
||||
QString filepath() const;
|
||||
void setFilepath(const QString& path);
|
||||
bool readWellPathFile(QString * errorMessage, RifWellPathImporter* wellPathImporter);
|
||||
int wellPathIndexInFile() const; // -1 means none.
|
||||
void setWellPathIndexInFile(int index);
|
||||
void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath) override;
|
||||
|
||||
private:
|
||||
QString surveyType() { return m_surveyType; }
|
||||
void setSurveyType(QString surveyType);
|
||||
bool isStoredInCache();
|
||||
QString getCacheFileName();
|
||||
QString getCacheDirectoryPath();
|
||||
|
||||
virtual void setupBeforeSave() override;
|
||||
|
||||
caf::PdmField<QString> m_filepath;
|
||||
caf::PdmField<int> m_wellPathIndexInFile; // -1 means none.
|
||||
|
||||
caf::PdmField<QString> id;
|
||||
caf::PdmField<QString> sourceSystem;
|
||||
caf::PdmField<QString> utmZone;
|
||||
caf::PdmField<QString> updateDate;
|
||||
caf::PdmField<QString> updateUser;
|
||||
caf::PdmField<QString> m_surveyType;
|
||||
|
||||
|
||||
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
|
||||
};
|
@ -54,6 +54,7 @@
|
||||
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
#include "RimFileWellPath.h"
|
||||
|
||||
namespace caf
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user