#2609 WIP: Refactor RimWellPath into RimFileWellPath

This commit is contained in:
Jacob Støren
2018-06-20 08:55:27 +02:00
parent d0f8e6afe4
commit 69e81658a6
5 changed files with 177 additions and 99 deletions

View File

@@ -193,11 +193,11 @@ bool RimWellLogFile::readFile(QString* errorMessage)
m_wellLogChannelNames.push_back(wellLog); m_wellLogChannelNames.push_back(wellLog);
} }
RimWellPath* wellPath; RimFileWellPath* wellPath;
firstAncestorOrThisOfType(wellPath); this->firstAncestorOrThisOfType(wellPath);
if (wellPath) if (wellPath)
{ {
if (wellPath->filepath().isEmpty()) if (wellPath->filepath().isEmpty()) // Has dummy wellpath
{ {
wellPath->setName(m_wellName); wellPath->setName(m_wellName);
} }

View File

@@ -55,7 +55,7 @@
#include <regex> #include <regex>
CAF_PDM_SOURCE_INIT(RimWellPath, "WellPath"); CAF_PDM_SOURCE_INIT(RimWellPath, "WellPathBase");
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
@@ -74,30 +74,6 @@ RimWellPath::RimWellPath()
m_name.xmlCapability()->setIOWritable(false); m_name.xmlCapability()->setIOWritable(false);
m_name.xmlCapability()->setIOReadable(false); m_name.xmlCapability()->setIOReadable(false);
m_name.uiCapability()->setUiHidden(true); m_name.uiCapability()->setUiHidden(true);
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_InitFieldNoDefault(&m_datumElevation, "DatumElevation", "Datum Elevation", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_datumElevation, "DatumElevation", "Datum Elevation", "", "", "");
m_datumElevation.uiCapability()->setUiReadOnly(true); m_datumElevation.uiCapability()->setUiReadOnly(true);
@@ -107,11 +83,6 @@ RimWellPath::RimWellPath()
CAF_PDM_InitFieldNoDefault(&m_unitSystem, "UnitSystem", "Unit System", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_unitSystem, "UnitSystem", "Unit System", "", "", "");
m_unitSystem.uiCapability()->setUiReadOnly(true); m_unitSystem.uiCapability()->setUiReadOnly(true);
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);
CAF_PDM_InitField(&m_simWellName, "SimWellName", QString(""), "Well", "", "", ""); CAF_PDM_InitField(&m_simWellName, "SimWellName", QString(""), "Well", "", "", "");
CAF_PDM_InitField(&m_branchIndex, "SimBranchIndex", 0, "Branch", "", "", ""); CAF_PDM_InitField(&m_branchIndex, "SimBranchIndex", 0, "Branch", "", "", "");
@@ -190,7 +161,7 @@ caf::PdmFieldHandle* RimWellPath::userDescriptionField()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellPath::setSurveyType(QString surveyType) void RimFileWellPath::setSurveyType(QString surveyType)
{ {
m_surveyType = surveyType; m_surveyType = surveyType;
if (m_surveyType == "PLAN") if (m_surveyType == "PLAN")
@@ -199,6 +170,29 @@ void RimWellPath::setSurveyType(QString surveyType)
m_wellPathColor = cvf::Color3f(0.0f, 0.333f, 0.999f); m_wellPathColor = cvf::Color3f(0.0f, 0.333f, 0.999f);
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFileWellPath::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{
RimWellPath::defineUiOrdering(uiConfigName, uiOrdering);
// Todo : Insert at correct place
caf::PdmUiGroup* fileInfoGroup = uiOrdering.addNewGroup("File");
fileInfoGroup->add(&m_filepath);
fileInfoGroup->add(&m_wellPathIndexInFile);
caf::PdmUiGroup* ssihubGroup = uiOrdering.addNewGroup("Well Info");
ssihubGroup->add(&id);
ssihubGroup->add(&sourceSystem);
ssihubGroup->add(&utmZone);
ssihubGroup->add(&updateDate);
ssihubGroup->add(&updateUser);
ssihubGroup->add(&m_surveyType);
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -413,10 +407,58 @@ std::vector<RimWellLogFile*> RimWellPath::wellLogFiles() const
return std::vector<RimWellLogFile*>(m_wellLogFiles.begin(), m_wellLogFiles.end()); return std::vector<RimWellLogFile*>(m_wellLogFiles.begin(), m_wellLogFiles.end());
} }
CAF_PDM_SOURCE_INIT(RimFileWellPath, "WellPath");
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QString RimWellPath::filepath() const 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(); return m_filepath();
} }
@@ -424,7 +466,7 @@ QString RimWellPath::filepath() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellPath::setFilepath(const QString& path) void RimFileWellPath::setFilepath(const QString& path)
{ {
m_filepath = path; m_filepath = path;
} }
@@ -432,7 +474,7 @@ void RimWellPath::setFilepath(const QString& path)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
int RimWellPath::wellPathIndexInFile() const int RimFileWellPath::wellPathIndexInFile() const
{ {
return m_wellPathIndexInFile(); return m_wellPathIndexInFile();
} }
@@ -440,7 +482,7 @@ int RimWellPath::wellPathIndexInFile() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellPath::setWellPathIndexInFile(int index) void RimFileWellPath::setWellPathIndexInFile(int index)
{ {
m_wellPathIndexInFile = index ; m_wellPathIndexInFile = index ;
} }
@@ -488,7 +530,7 @@ caf::PdmFieldHandle* RimWellPath::objectToggleField()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// Read JSON or ascii file containing well path data /// Read JSON or ascii file containing well path data
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RimWellPath::readWellPathFile(QString* errorMessage, RifWellPathImporter* wellPathImporter) bool RimFileWellPath::readWellPathFile(QString* errorMessage, RifWellPathImporter* wellPathImporter)
{ {
if (caf::Utils::fileExists(m_filepath())) if (caf::Utils::fileExists(m_filepath()))
{ {
@@ -538,9 +580,6 @@ void RimWellPath::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiO
appGroup->add(&m_wellPathColor); appGroup->add(&m_wellPathColor);
appGroup->add(&m_wellPathRadiusScaleFactor); appGroup->add(&m_wellPathRadiusScaleFactor);
caf::PdmUiGroup* fileInfoGroup = uiOrdering.addNewGroup("File");
fileInfoGroup->add(&m_filepath);
fileInfoGroup->add(&m_wellPathIndexInFile);
caf::PdmUiGroup* simWellGroup = uiOrdering.addNewGroup("Simulation Well"); caf::PdmUiGroup* simWellGroup = uiOrdering.addNewGroup("Simulation Well");
simWellGroup->add(&m_simWellName); simWellGroup->add(&m_simWellName);
@@ -551,12 +590,7 @@ void RimWellPath::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiO
} }
caf::PdmUiGroup* ssihubGroup = uiOrdering.addNewGroup("Well Info"); caf::PdmUiGroup* ssihubGroup = uiOrdering.addNewGroup("Well Info");
ssihubGroup->add(&id);
ssihubGroup->add(&sourceSystem);
ssihubGroup->add(&utmZone);
ssihubGroup->add(&updateDate);
ssihubGroup->add(&updateUser);
ssihubGroup->add(&m_surveyType);
ssihubGroup->add(&m_datumElevation); ssihubGroup->add(&m_datumElevation);
ssihubGroup->add(&m_unitSystem); ssihubGroup->add(&m_unitSystem);
@@ -600,7 +634,7 @@ void RimWellPath::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, Q
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QString RimWellPath::getCacheDirectoryPath() QString RimFileWellPath::getCacheDirectoryPath()
{ {
QString cacheDirPath = RimTools::getCacheRootDirectoryPathFromProject(); QString cacheDirPath = RimTools::getCacheRootDirectoryPathFromProject();
cacheDirPath += "_wellpaths"; cacheDirPath += "_wellpaths";
@@ -610,7 +644,7 @@ QString RimWellPath::getCacheDirectoryPath()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QString RimWellPath::getCacheFileName() QString RimFileWellPath::getCacheFileName()
{ {
if (m_filepath().isEmpty()) if (m_filepath().isEmpty())
{ {
@@ -632,7 +666,7 @@ QString RimWellPath::getCacheFileName()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellPath::setupBeforeSave() 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 // 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()) if (!isStoredInCache())
@@ -676,7 +710,7 @@ size_t RimWellPath::simulationWellBranchCount(const QString& simWellName)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
bool RimWellPath::isStoredInCache() 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 // 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(); return !id().isEmpty();
@@ -685,8 +719,10 @@ bool RimWellPath::isStoredInCache()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellPath::updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath) void RimFileWellPath::updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath)
{ {
RimWellPath::updateFilePathsFromProjectPath(newProjectPath, oldProjectPath);
if (isStoredInCache()) if (isStoredInCache())
{ {
QString newCacheFileName = getCacheFileName(); QString newCacheFileName = getCacheFileName();
@@ -700,6 +736,13 @@ void RimWellPath::updateFilePathsFromProjectPath(const QString& newProjectPath,
{ {
m_filepath = RimTools::relocateFile(m_filepath(), newProjectPath, oldProjectPath, nullptr, nullptr); m_filepath = RimTools::relocateFile(m_filepath(), newProjectPath, oldProjectPath, nullptr, nullptr);
} }
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPath::updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath)
{
{ {
bool foundFile = false; bool foundFile = false;

View File

@@ -77,12 +77,7 @@ public:
bool tryAssociateWithSimulationWell(); bool tryAssociateWithSimulationWell();
bool isAssociatedWithSimulationWell() const; bool isAssociatedWithSimulationWell() const;
QString filepath() const; virtual void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath);
void setFilepath(const QString& path);
bool readWellPathFile(QString * errorMessage, RifWellPathImporter* wellPathImporter);
void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath);
int wellPathIndexInFile() const; // -1 means none.
void setWellPathIndexInFile(int index);
void setUnitSystem(RiaEclipseUnitTools::UnitSystem unitSystem); void setUnitSystem(RiaEclipseUnitTools::UnitSystem unitSystem);
RiaEclipseUnitTools::UnitSystem unitSystem() const; RiaEclipseUnitTools::UnitSystem unitSystem() const;
@@ -132,21 +127,15 @@ protected:
virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;
virtual void initAfterRead() override; virtual void initAfterRead() override;
virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
private: private:
void setWellPathGeometry(RigWellPath* wellPathModel); void setWellPathGeometry(RigWellPath* wellPathModel);
QString surveyType() { return m_surveyType; }
void setSurveyType(QString surveyType);
virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName) override; virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName) override;
bool isStoredInCache();
QString getCacheFileName();
QString getCacheDirectoryPath();
virtual void setupBeforeSave() override;
static size_t simulationWellBranchCount(const QString& simWellName); static size_t simulationWellBranchCount(const QString& simWellName);
@@ -155,27 +144,17 @@ private:
caf::PdmField<QString> m_name; caf::PdmField<QString> m_name;
caf::PdmField<QString> m_filepath;
caf::PdmField<int> m_wellPathIndexInFile; // -1 means none.
caf::PdmField<QString> m_simWellName; caf::PdmField<QString> m_simWellName;
caf::PdmField<int> m_branchIndex; caf::PdmField<int> m_branchIndex;
caf::PdmField<RiaEclipseUnitTools::UnitSystemType> m_unitSystem; caf::PdmField<RiaEclipseUnitTools::UnitSystemType> m_unitSystem;
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;
caf::PdmField<double> m_datumElevation; caf::PdmField<double> m_datumElevation;
caf::PdmField<QString> m_wellPathFormationFilePath; caf::PdmField<QString> m_wellPathFormationFilePath;
caf::PdmField<QString> m_formationKeyInFile; caf::PdmField<QString> m_formationKeyInFile;
caf::PdmField<cvf::Color3f> m_wellPathColor;
caf::PdmField<bool> m_showWellPath; caf::PdmField<bool> m_showWellPath;
caf::PdmField<bool> m_showWellPathLabel; caf::PdmField<bool> m_showWellPathLabel;
@@ -188,10 +167,53 @@ private:
// Geometry and data // Geometry and data
cvf::ref<RigWellPath> m_wellPath;
cvf::ref<RigWellPathFormations> m_wellPathFormations; cvf::ref<RigWellPathFormations> m_wellPathFormations;
protected:
cvf::ref<RigWellPath> m_wellPath;
caf::PdmField<cvf::Color3f> m_wellPathColor;
private:
// Obsolete fields // Obsolete fields
caf::PdmChildField<RimWellLogFile*> m_wellLogFile_OBSOLETE; 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;
};

View File

@@ -133,10 +133,13 @@ void RimWellPathCollection::readWellPathFiles()
for (size_t wpIdx = 0; wpIdx < wellPaths.size(); wpIdx++) for (size_t wpIdx = 0; wpIdx < wellPaths.size(); wpIdx++)
{ {
if (!wellPaths[wpIdx]->filepath().isEmpty()) RimFileWellPath* fWPath = dynamic_cast<RimFileWellPath*>(wellPaths[wpIdx]);
if (fWPath)
{
if (!fWPath->filepath().isEmpty())
{ {
QString errorMessage; QString errorMessage;
if (!wellPaths[wpIdx]->readWellPathFile(&errorMessage, m_wellPathImporter)) if (!fWPath->readWellPathFile(&errorMessage, m_wellPathImporter))
{ {
QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(),
"File open error", "File open error",
@@ -144,7 +147,7 @@ void RimWellPathCollection::readWellPathFiles()
} }
} }
for (RimWellLogFile* const wellLogFile : wellPaths[wpIdx]->wellLogFiles()) for (RimWellLogFile* const wellLogFile : fWPath->wellLogFiles())
{ {
if (wellLogFile) if (wellLogFile)
{ {
@@ -165,6 +168,7 @@ void RimWellPathCollection::readWellPathFiles()
} }
} }
} }
}
progress.setProgressDescription(QString("Reading file %1").arg(wellPaths[wpIdx]->name())); progress.setProgressDescription(QString("Reading file %1").arg(wellPaths[wpIdx]->name()));
progress.incrementProgress(); progress.incrementProgress();
} }
@@ -178,7 +182,7 @@ void RimWellPathCollection::readWellPathFiles()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellPathCollection::addWellPaths( QStringList filePaths ) void RimWellPathCollection::addWellPaths( QStringList filePaths )
{ {
std::vector<RimWellPath*> wellPathArray; std::vector<RimFileWellPath*> wellPathArray;
for (QString filePath : filePaths) for (QString filePath : filePaths)
{ {
@@ -186,11 +190,14 @@ void RimWellPathCollection::addWellPaths( QStringList filePaths )
bool alreadyOpen = false; bool alreadyOpen = false;
for (size_t wpIdx = 0; wpIdx < wellPaths.size(); wpIdx++) for (size_t wpIdx = 0; wpIdx < wellPaths.size(); wpIdx++)
{ {
RimFileWellPath* fWPath = dynamic_cast<RimFileWellPath*>(wellPaths[wpIdx]);
if (!fWPath) continue;
QFile f1; QFile f1;
f1.setFileName(filePath); f1.setFileName(filePath);
QString s1 = f1.fileName(); QString s1 = f1.fileName();
QFile f2; QFile f2;
f2.setFileName(wellPaths[wpIdx]->filepath()); f2.setFileName(fWPath->filepath());
QString s2 = f2.fileName(); QString s2 = f2.fileName();
if (s1 == s2) if (s1 == s2)
{ {
@@ -206,7 +213,7 @@ void RimWellPathCollection::addWellPaths( QStringList filePaths )
if (fi.suffix().compare("json") == 0) if (fi.suffix().compare("json") == 0)
{ {
RimWellPath* wellPath = new RimWellPath(); RimFileWellPath* wellPath = new RimFileWellPath();
wellPath->setFilepath(filePath); wellPath->setFilepath(filePath);
wellPathArray.push_back(wellPath); wellPathArray.push_back(wellPath);
} }
@@ -216,7 +223,7 @@ void RimWellPathCollection::addWellPaths( QStringList filePaths )
size_t wellPathCount = m_wellPathImporter->wellDataCount(filePath); size_t wellPathCount = m_wellPathImporter->wellDataCount(filePath);
for (size_t i = 0; i < wellPathCount; ++i) for (size_t i = 0; i < wellPathCount; ++i)
{ {
RimWellPath* wellPath = new RimWellPath(); RimFileWellPath* wellPath = new RimFileWellPath();
wellPath->setFilepath(filePath); wellPath->setFilepath(filePath);
wellPath->setWellPathIndexInFile(static_cast<int>(i)); wellPath->setWellPathIndexInFile(static_cast<int>(i));
wellPathArray.push_back(wellPath); wellPathArray.push_back(wellPath);
@@ -236,7 +243,7 @@ void RimWellPathCollection::addWellPaths( QStringList filePaths )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellPathCollection::readAndAddWellPaths(std::vector<RimWellPath*>& wellPathArray) void RimWellPathCollection::readAndAddWellPaths(std::vector<RimFileWellPath*>& wellPathArray)
{ {
caf::ProgressInfo progress(wellPathArray.size(), "Reading well paths from file"); caf::ProgressInfo progress(wellPathArray.size(), "Reading well paths from file");
@@ -251,13 +258,13 @@ void RimWellPathCollection::readAndAddWellPaths(std::vector<RimWellPath*>& wellP
for (size_t wpIdx = 0; wpIdx < wellPathArray.size(); wpIdx++) for (size_t wpIdx = 0; wpIdx < wellPathArray.size(); wpIdx++)
{ {
RimWellPath* wellPath = wellPathArray[wpIdx]; RimFileWellPath* wellPath = wellPathArray[wpIdx];
wellPath->readWellPathFile(nullptr, m_wellPathImporter); wellPath->readWellPathFile(nullptr, m_wellPathImporter);
progress.setProgressDescription(QString("Reading file %1").arg(wellPath->name())); progress.setProgressDescription(QString("Reading file %1").arg(wellPath->name()));
// If a well path with this name exists already, make it read the well path file // If a well path with this name exists already, make it read the well path file
RimWellPath* existingWellPath = tryFindMatchingWellPath(wellPath->name()); RimFileWellPath* existingWellPath = dynamic_cast< RimFileWellPath*>( tryFindMatchingWellPath(wellPath->name()));
if (existingWellPath) if (existingWellPath)
{ {
existingWellPath->setFilepath(wellPath->filepath()); existingWellPath->setFilepath(wellPath->filepath());
@@ -528,21 +535,26 @@ void RimWellPathCollection::removeWellPath(RimWellPath* wellPath)
{ {
wellPaths.removeChildObject(wellPath); wellPaths.removeChildObject(wellPath);
bool isFilePathUsed = false; RimFileWellPath* fileWellPath = dynamic_cast<RimFileWellPath*>(wellPath);
for (size_t i = 0; i < wellPaths.size(); i++) if ( fileWellPath )
{ {
if (wellPaths[i]->filepath() == wellPath->filepath()) bool isFilePathUsed = false;
for ( size_t i = 0; i < wellPaths.size(); i++ )
{
RimFileWellPath* fWPath = dynamic_cast<RimFileWellPath*>(wellPaths[i]);
if (fWPath && fWPath->filepath() == fileWellPath->filepath() )
{ {
isFilePathUsed = true; isFilePathUsed = true;
break; break;
} }
} }
if (!isFilePathUsed) if ( !isFilePathUsed )
{ {
// One file can have multiple well paths // One file can have multiple well paths
// If no other well paths are referencing the filepath, remove cached data from the file reader // If no other well paths are referencing the filepath, remove cached data from the file reader
m_wellPathImporter->removeFilePath(wellPath->filepath()); m_wellPathImporter->removeFilePath(fileWellPath->filepath());
}
} }
} }

View File

@@ -36,6 +36,7 @@
class RifWellPathImporter; class RifWellPathImporter;
class RigWellPath; class RigWellPath;
class RimFileWellPath;
class RimEclipseView; class RimEclipseView;
class RimProject; class RimProject;
class RimWellLogFile; class RimWellLogFile;
@@ -116,7 +117,7 @@ private:
virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
virtual caf::PdmFieldHandle* objectToggleField() override; virtual caf::PdmFieldHandle* objectToggleField() override;
void readAndAddWellPaths(std::vector<RimWellPath*>& wellPathArray); void readAndAddWellPaths(std::vector<RimFileWellPath*>& wellPathArray);
void sortWellsByName(); void sortWellsByName();
RiaEclipseUnitTools::UnitSystemType findUnitSystemForWellPath(const RimWellPath* wellPath); RiaEclipseUnitTools::UnitSystemType findUnitSystemForWellPath(const RimWellPath* wellPath);