#2122 Formation/Well Path: Set formations path and key on RimWellPath

This commit is contained in:
Rebecca Cox 2017-11-27 10:33:41 +01:00
parent 5ed072007d
commit 8c57fdf22a
10 changed files with 103 additions and 50 deletions

View File

@ -799,7 +799,10 @@ void RiaApplication::addWellPathFormationsToModel(QList<QString> wellPathFormati
m_project->updateConnectedEditors();
}
if (oilField->wellPathCollection) oilField->wellPathCollection->addWellFormations(wellPathFormationsFilePaths);
if (oilField->wellPathCollection)
{
oilField->wellPathCollection->addWellPathFormations(wellPathFormationsFilePaths);
}
oilField->wellPathCollection->updateConnectedEditors();
}

View File

@ -36,7 +36,8 @@ std::map<QString, std::vector<std::pair<double, QString>>> RifWellPathFormationR
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::map<QString, cvf::ref<RigWellPathFormations>> RifWellPathFormationReader::readWellFormationsToGeometry(const QString& filePath)
std::map<QString, cvf::ref<RigWellPathFormations>>
RifWellPathFormationReader::readWellFormationsToGeometry(const QString& filePath)
{
std::map<QString, cvf::ref<RigWellPathFormations>> result;
@ -48,9 +49,10 @@ std::map<QString, cvf::ref<RigWellPathFormations>> RifWellPathFormationReader::r
for (it = formations.begin(); it != formations.end(); it++)
{
cvf::ref<RigWellPathFormations> wellPathFormations = new RigWellPathFormations(it->second);
result[it->first] = wellPathFormations;
cvf::ref<RigWellPathFormations> wellPathFormations = new RigWellPathFormations(it->second, filePath, it->first);
result[it->first] = wellPathFormations;
}
return result;
}

View File

@ -26,7 +26,33 @@ cvf::ref<RigWellPathFormations> RifWellPathFormationsImporter::readWellPathForma
const QString& wellName)
{
readAllWellPathFormations(formationFilePath);
return m_fileNameToWellPathFormationMap[formationFilePath][wellName];
if (m_fileNameToWellPathFormationMap[formationFilePath].find(wellName) != m_fileNameToWellPathFormationMap[formationFilePath].end())
{
return m_fileNameToWellPathFormationMap[formationFilePath][wellName];
}
else
{
return nullptr;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::map<QString, cvf::ref<RigWellPathFormations>> RifWellPathFormationsImporter::readWellPathFormationsFromPath(const QString& filePath)
{
// If we have the file in the map, assume it is already read.
if (m_fileNameToWellPathFormationMap.find(filePath) != m_fileNameToWellPathFormationMap.end())
{
return m_fileNameToWellPathFormationMap[filePath];
}
std::map<QString, cvf::ref<RigWellPathFormations>> wellPathToFormationMap =
RifWellPathFormationReader::readWellFormationsToGeometry(filePath);
m_fileNameToWellPathFormationMap[filePath] = wellPathToFormationMap;
return wellPathToFormationMap;
}
//--------------------------------------------------------------------------------------------------

View File

@ -38,6 +38,8 @@ class RifWellPathFormationsImporter
public:
cvf::ref<RigWellPathFormations> readWellPathFormations(const QString& formationFilePath, const QString& wellName);
std::map<QString, cvf::ref<RigWellPathFormations>> readWellPathFormationsFromPath(const QString& filePath);
private:
void readAllWellPathFormations(const QString& filePath);

View File

@ -106,7 +106,7 @@ RimWellPath::RimWellPath()
CAF_PDM_InitFieldNoDefault(&m_unitSystem, "UnitSystem", "Unit System", "", "", "");
m_unitSystem.uiCapability()->setUiReadOnly(true);
CAF_PDM_InitField(&filepath, "WellPathFilepath", QString(""), "Filepath", "", "", "");
CAF_PDM_InitField(&filepath, "WellPathFilepath", QString(""), "File Path", "", "", "");
filepath.uiCapability()->setUiReadOnly(true);
CAF_PDM_InitField(&wellPathIndexInFile, "WellPathNumberInFile", -1, "Well Number in file", "", "", "");
wellPathIndexInFile.uiCapability()->setUiReadOnly(true);
@ -129,11 +129,17 @@ RimWellPath::RimWellPath()
CAF_PDM_InitFieldNoDefault(&m_wellLogFiles, "WellLogFiles", "Well Log Files", "", "", "");
m_wellLogFiles.uiCapability()->setUiTreeHidden(true);
CAF_PDM_InitField(&m_formationKeyInFile, "WellPathFormationKeyInFile", QString(""), "Key in File", "", "", "");
m_formationKeyInFile.uiCapability()->setUiReadOnly(true);
CAF_PDM_InitField(&m_wellPathFormationFilePath, "WellPathFormationFilePath", QString(""), "File Path", "", "", "");
m_wellPathFormationFilePath.uiCapability()->setUiReadOnly(true);
CAF_PDM_InitFieldNoDefault(&m_wellLogFile_OBSOLETE, "WellLogFile", "Well Log File", "", "", "");
m_wellLogFile_OBSOLETE.uiCapability()->setUiHidden(true);
m_wellLogFile_OBSOLETE.xmlCapability()->setIOWritable(false);
m_wellPath = NULL;
m_wellPath = nullptr;
}
@ -489,6 +495,10 @@ void RimWellPath::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiO
m_datumElevation.uiCapability()->setUiHidden(true);
}
caf::PdmUiGroup* formationFileInfoGroup = uiOrdering.addNewGroup("Formation Names");
formationFileInfoGroup->add(&m_wellPathFormationFilePath);
formationFileInfoGroup->add(&m_formationKeyInFile);
uiOrdering.skipRemainingFields(true);
}
@ -596,7 +606,7 @@ void RimWellPath::updateFilePathsFromProjectPath(const QString& newProjectPath,
}
else
{
filepath = RimTools::relocateFile(filepath(), newProjectPath, oldProjectPath, NULL, NULL);
filepath = RimTools::relocateFile(filepath(), newProjectPath, oldProjectPath, nullptr, nullptr);
}
}
@ -681,17 +691,13 @@ void RimWellPath::detachWellLogFile(RimWellLogFile* logFileInfo)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPath::setWellFormationFile(const QString& formationFilePath)
void RimWellPath::setFormationsGeometry(cvf::ref<RigWellPathFormations> wellPathFormations)
{
m_wellPathFormationFilePath = formationFilePath;
}
m_wellPathFormations = wellPathFormations;
m_wellPathFormationFilePath = wellPathFormations->filePath();
m_formationKeyInFile = wellPathFormations->keyInFile();
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimWellPath::wellFormationFile() const
{
return m_wellPathFormationFilePath;
updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
@ -699,9 +705,18 @@ QString RimWellPath::wellFormationFile() const
//--------------------------------------------------------------------------------------------------
bool RimWellPath::readWellPathFormationsFile(QString* errorMessage, RifWellPathFormationsImporter* wellPathFormationsImporter)
{
if (m_wellPathFormationFilePath().isEmpty())
{
return true;
}
if (caf::Utils::fileExists(m_wellPathFormationFilePath()))
{
m_wellPathFormations = wellPathFormationsImporter->readWellPathFormations(m_wellPathFormationFilePath(), m_name());
m_wellPathFormations = wellPathFormationsImporter->readWellPathFormations(m_wellPathFormationFilePath(), m_formationKeyInFile());
if (m_name().isEmpty())
{
setName(m_formationKeyInFile());
}
return true;
}
else

View File

@ -72,8 +72,7 @@ public:
void deleteWellLogFile(RimWellLogFile* logFileInfo);
void detachWellLogFile(RimWellLogFile* logFileInfo);
void setWellFormationFile(const QString& formationFilePath);
QString wellFormationFile() const;
void setFormationsGeometry(cvf::ref<RigWellPathFormations> wellPathFormations);
bool readWellPathFormationsFile(QString* errorMessage, RifWellPathFormationsImporter* wellPathFormationsImporter);
virtual caf::PdmFieldHandle* userDescriptionField() override;
@ -167,6 +166,8 @@ private:
cvf::ref<RivWellPathPartMgr> m_wellPathPartMgr;
caf::PdmField<QString> m_name;
caf::PdmField<QString> m_formationKeyInFile;
caf::PdmChildArrayField<RimWellLogFile*> m_wellLogFiles;
caf::PdmField<QString> m_wellPathFormationFilePath;

View File

@ -330,29 +330,27 @@ RimWellLogFile* RimWellPathCollection::addWellLogs(const QStringList& filePaths)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellPathFormations* RimWellPathCollection::addWellFormations(const QStringList& filePaths)
void RimWellPathCollection::addWellPathFormations(const QStringList& filePaths)
{
RimWellPathFormations* wellFormationFile = nullptr;
/*
foreach(QString filePath, filePaths)
for (QString filePath : filePaths)
{
wellFormationFile = RimWellPathFormations::readWellLogFile(filePath);
if (wellFormationFile)
std::map<QString, cvf::ref<RigWellPathFormations>> newFormations =
m_wellPathFormationsImporter->readWellPathFormationsFromPath(filePath);
for (auto it = newFormations.begin(); it != newFormations.end(); it++)
{
RimWellPath* wellPath = tryFindMatchingWellPath(wellFormationFile->wellName());
RimWellPath* wellPath = tryFindMatchingWellPath(it->first);
if (!wellPath)
{
wellPath = new RimWellPath();
wellPath->setName(it->first);
wellPaths.push_back(wellPath);
}
wellPath->setWellFormationFile(wellFormationFile);
wellPath->setFormationsGeometry(it->second);
}
}
this->sortWellsByName();*/
return wellFormationFile;
this->sortWellsByName();
}
//--------------------------------------------------------------------------------------------------
@ -503,15 +501,12 @@ void RimWellPathCollection::readWellPathFormationFiles()
for (size_t wpIdx = 0; wpIdx < wellPaths.size(); wpIdx++)
{
if (!wellPaths[wpIdx]->filepath().isEmpty())
QString errorMessage;
if (!wellPaths[wpIdx]->readWellPathFormationsFile(&errorMessage, m_wellPathFormationsImporter))
{
QString errorMessage;
if (!wellPaths[wpIdx]->readWellPathFormationsFile(&errorMessage, m_wellPathFormationsImporter))
{
QMessageBox::warning(RiuMainWindow::instance(),
"File open error",
errorMessage);
}
QMessageBox::warning(RiuMainWindow::instance(),
"File open error",
errorMessage);
}
progress.setProgressDescription(QString("Reading formation file %1").arg(wpIdx));

View File

@ -40,7 +40,6 @@ class RimEclipseView;
class RimProject;
class RimWellLogFile;
class RimWellPath;
class RimWellPathFormations;
class RifWellPathFormationsImporter;
class QString;
@ -102,7 +101,7 @@ public:
RimWellPath* tryFindMatchingWellPath(const QString& wellName) const;
void addWellPaths(const std::vector<RimWellPath*> wellPaths);
RimWellLogFile* addWellLogs(const QStringList& filePaths);
RimWellPathFormations* addWellFormations(const QStringList& filePaths);
void addWellPathFormations(const QStringList& filePaths);
void scheduleRedrawAffectedViews();

View File

@ -18,20 +18,28 @@
#include "RigWellPathFormations.h"
#include "RifWellPathFormationReader.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigWellPathFormations::RigWellPathFormations(std::vector<std::pair<double, QString>> measuredDepthAndFormationNames)
RigWellPathFormations::RigWellPathFormations(std::vector<std::pair<double, QString>> measuredDepthAndFormationNames, const QString& filePath, const QString& key)
{
m_measuredDepthAndFormationNames = measuredDepthAndFormationNames;
m_filePath = filePath;
m_keyInFile = key;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RigWellPathFormations::wellName() const
QString RigWellPathFormations::filePath() const
{
return m_wellName;
return m_filePath;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RigWellPathFormations::keyInFile() const
{
return m_keyInFile;
}

View File

@ -30,12 +30,14 @@
class RigWellPathFormations : public cvf::Object
{
public:
RigWellPathFormations(std::vector<std::pair<double, QString>> measuredDepthAndFormationNames);
RigWellPathFormations(std::vector<std::pair<double, QString>> measuredDepthAndFormationNames, const QString& filePath, const QString& key);
QString wellName() const;
QString filePath() const;
QString keyInFile() const;
private:
QString m_wellName;
QString m_filePath;
QString m_keyInFile;
std::vector<std::pair<double, QString>> m_measuredDepthAndFormationNames;
};