#2609 Cleanup RimWellPath ready for refactor into two classes

This commit is contained in:
Jacob Støren 2018-06-18 17:13:30 +02:00
parent 22bf33d02f
commit 5059201126
4 changed files with 186 additions and 117 deletions

View File

@ -330,7 +330,7 @@ void RimWellLogTrack::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
{
if (m_formationWellPathForSourceCase)
{
m_formationSimWellName = m_formationWellPathForSourceCase->m_simWellName;
m_formationSimWellName = m_formationWellPathForSourceCase->associatedSimulationWellName();
}
}

View File

@ -107,21 +107,21 @@ RimWellPath::RimWellPath()
CAF_PDM_InitFieldNoDefault(&m_unitSystem, "UnitSystem", "Unit System", "", "", "");
m_unitSystem.uiCapability()->setUiReadOnly(true);
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);
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_branchIndex, "SimBranchIndex", 0, "Branch", "", "", "");
CAF_PDM_InitField(&showWellPathLabel, "ShowWellPathLabel", true, "Show Well Path Label", "", "", "");
CAF_PDM_InitField(&m_showWellPathLabel, "ShowWellPathLabel", true, "Show Well Path Label", "", "", "");
CAF_PDM_InitField(&showWellPath, "ShowWellPath", true, "Show Well Path", "", "", "");
showWellPath.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&m_showWellPath, "ShowWellPath", true, "Show Well Path", "", "", "");
m_showWellPath.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&wellPathRadiusScaleFactor, "WellPathRadiusScale", 1.0, "Well Path Radius Scale", "", "", "");
CAF_PDM_InitField(&wellPathColor, "WellPathColor", cvf::Color3f(0.999f, 0.333f, 0.999f), "Well Path Color", "", "", "");
CAF_PDM_InitField(&m_wellPathRadiusScaleFactor, "WellPathRadiusScale", 1.0, "Well Path Radius Scale", "", "", "");
CAF_PDM_InitField(&m_wellPathColor, "WellPathColor", cvf::Color3f(0.999f, 0.333f, 0.999f), "Well Path Color", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_completions, "Completions", "Completions", "", "", "");
m_completions = new RimWellPathCompletions;
@ -194,9 +194,9 @@ void RimWellPath::setSurveyType(QString surveyType)
{
m_surveyType = surveyType;
if (m_surveyType == "PLAN")
wellPathColor = cvf::Color3f(0.999f, 0.333f, 0.0f);
m_wellPathColor = cvf::Color3f(0.999f, 0.333f, 0.0f);
else if (m_surveyType == "PROTOTYPE")
wellPathColor = cvf::Color3f(0.0f, 0.333f, 0.999f);
m_wellPathColor = cvf::Color3f(0.0f, 0.333f, 0.999f);
}
//--------------------------------------------------------------------------------------------------
@ -204,7 +204,7 @@ void RimWellPath::setSurveyType(QString surveyType)
//--------------------------------------------------------------------------------------------------
double RimWellPath::wellPathRadius(double characteristicCellSize) const
{
double radius = characteristicCellSize * wellPathRadiusScaleFactor();
double radius = characteristicCellSize * m_wellPathRadiusScaleFactor();
RimWellPathCollection* coll = nullptr;
this->firstAncestorOrThisOfType(coll);
@ -216,6 +216,14 @@ double RimWellPath::wellPathRadius(double characteristicCellSize) const
return radius;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimWellPath::wellPathRadiusScaleFactor() const
{
return m_wellPathRadiusScaleFactor();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -307,7 +315,7 @@ void RimWellPath::fieldChangedByUi(const caf::PdmFieldHandle* changedField, cons
{
RimProject* proj;
this->firstAncestorOrThisOfTypeAsserted(proj);
if (changedField == &showWellPath)
if (changedField == &m_showWellPath)
{
proj->reloadCompletionTypeResultsInAllViews();
}
@ -405,12 +413,76 @@ std::vector<RimWellLogFile*> RimWellPath::wellLogFiles() const
return std::vector<RimWellLogFile*>(m_wellLogFiles.begin(), m_wellLogFiles.end());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimWellPath::filepath() const
{
return m_filepath();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPath::setFilepath(const QString& path)
{
m_filepath = path;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimWellPath::wellPathIndexInFile() const
{
return m_wellPathIndexInFile();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPath::setWellPathIndexInFile(int index)
{
m_wellPathIndexInFile = index ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellPath::showWellPathLabel() const
{
return m_showWellPathLabel();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellPath::showWellPath() const
{
return m_showWellPath();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Color3f RimWellPath::wellPathColor() const
{
return m_wellPathColor;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPath::setWellPathColor(const cvf::Color3f& color)
{
m_wellPathColor = color;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimWellPath::objectToggleField()
{
return &showWellPath;
return &m_showWellPath;
}
//--------------------------------------------------------------------------------------------------
@ -418,10 +490,10 @@ caf::PdmFieldHandle* RimWellPath::objectToggleField()
//--------------------------------------------------------------------------------------------------
bool RimWellPath::readWellPathFile(QString* errorMessage, RifWellPathImporter* wellPathImporter)
{
if (caf::Utils::fileExists(filepath()))
if (caf::Utils::fileExists(m_filepath()))
{
RifWellPathImporter::WellData wellData = wellPathImporter->readWellData(filepath(), wellPathIndexInFile());
RifWellPathImporter::WellMetaData wellMetaData = wellPathImporter->readWellMetaData(filepath(), wellPathIndexInFile());
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);
@ -437,7 +509,7 @@ bool RimWellPath::readWellPathFile(QString* errorMessage, RifWellPathImporter* w
}
else
{
if (errorMessage) (*errorMessage) = "Could not find the well path file: " + filepath();
if (errorMessage) (*errorMessage) = "Could not find the well path file: " + m_filepath();
return false;
}
}
@ -462,13 +534,13 @@ void RimWellPath::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiO
}
caf::PdmUiGroup* appGroup = uiOrdering.addNewGroup("Appearance");
appGroup->add(&showWellPathLabel);
appGroup->add(&wellPathColor);
appGroup->add(&wellPathRadiusScaleFactor);
appGroup->add(&m_showWellPathLabel);
appGroup->add(&m_wellPathColor);
appGroup->add(&m_wellPathRadiusScaleFactor);
caf::PdmUiGroup* fileInfoGroup = uiOrdering.addNewGroup("File");
fileInfoGroup->add(&filepath);
fileInfoGroup->add(&wellPathIndexInFile);
fileInfoGroup->add(&m_filepath);
fileInfoGroup->add(&m_wellPathIndexInFile);
caf::PdmUiGroup* simWellGroup = uiOrdering.addNewGroup("Simulation Well");
simWellGroup->add(&m_simWellName);
@ -540,7 +612,7 @@ QString RimWellPath::getCacheDirectoryPath()
//--------------------------------------------------------------------------------------------------
QString RimWellPath::getCacheFileName()
{
if (filepath().isEmpty())
if (m_filepath().isEmpty())
{
return "";
}
@ -549,7 +621,7 @@ QString RimWellPath::getCacheFileName()
// Make the path correct related to the possibly new project filename
QString newCacheDirPath = getCacheDirectoryPath();
QFileInfo oldCacheFile(filepath);
QFileInfo oldCacheFile(m_filepath);
cacheFileName = newCacheDirPath + "/" + oldCacheFile.fileName();
@ -568,7 +640,7 @@ void RimWellPath::setupBeforeSave()
return;
}
if (filepath().isEmpty())
if (m_filepath().isEmpty())
{
return;
}
@ -578,14 +650,14 @@ void RimWellPath::setupBeforeSave()
QString newCacheFileName = getCacheFileName();
// Use QFileInfo to get same string representation to avoid issues with mix of forward and backward slashes
QFileInfo prevFileInfo(filepath);
QFileInfo prevFileInfo(m_filepath);
QFileInfo currentFileInfo(newCacheFileName);
if (prevFileInfo.absoluteFilePath().compare(currentFileInfo.absoluteFilePath()) != 0)
{
QFile::copy(filepath, newCacheFileName);
QFile::copy(m_filepath, newCacheFileName);
filepath = newCacheFileName;
m_filepath = newCacheFileName;
}
}
@ -621,12 +693,12 @@ void RimWellPath::updateFilePathsFromProjectPath(const QString& newProjectPath,
if (caf::Utils::fileExists(newCacheFileName))
{
filepath = newCacheFileName;
m_filepath = newCacheFileName;
}
}
else
{
filepath = RimTools::relocateFile(filepath(), newProjectPath, oldProjectPath, nullptr, nullptr);
m_filepath = RimTools::relocateFile(m_filepath(), newProjectPath, oldProjectPath, nullptr, nullptr);
}
{
@ -650,7 +722,7 @@ double RimWellPath::combinedScaleFactor() const
RimWellPathCollection* wellPathColl = nullptr;
this->firstAncestorOrThisOfTypeAsserted(wellPathColl);
return this->wellPathRadiusScaleFactor() * wellPathColl->wellPathRadiusScaleFactor();
return this->m_wellPathRadiusScaleFactor() * wellPathColl->wellPathRadiusScaleFactor();
}
//--------------------------------------------------------------------------------------------------
@ -817,21 +889,6 @@ Rim3dWellLogCurveCollection* RimWellPath::rim3dWellLogCurveCollection() const
return m_3dWellLogCurves();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellPath* RimWellPath::fromFilePath(QString filePath)
{
RimWellLogFile* logFileInfo = RimWellLogFile::readWellLogFile(filePath);
if (logFileInfo)
{
auto wellPath = new RimWellPath();
wellPath->addWellLogFile(logFileInfo);
return wellPath;
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -69,9 +69,31 @@ public:
RimWellPath();
virtual ~RimWellPath();
QString name() const;
void setName(const QString& name);
const QString associatedSimulationWellName() const;
int associatedSimulationWellBranch() const;
bool tryAssociateWithSimulationWell();
bool isAssociatedWithSimulationWell() const;
QString filepath() const;
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);
RiaEclipseUnitTools::UnitSystem unitSystem() const;
RigWellPath* wellPathGeometry();
const RigWellPath* wellPathGeometry() const;
void addWellLogFile(RimWellLogFile* logFileInfo);
void deleteWellLogFile(RimWellLogFile* logFileInfo);
void detachWellLogFile(RimWellLogFile* logFileInfo);
std::vector<RimWellLogFile*> wellLogFiles() const;
void setFormationsGeometry(cvf::ref<RigWellPathFormations> wellPathFormations);
bool readWellPathFormationsFile(QString* errorMessage, RifWellPathFormationsImporter* wellPathFormationsImporter);
@ -82,6 +104,28 @@ public:
void add3dWellLogCurve(Rim3dWellLogCurve* rim3dWellLogCurve);
Rim3dWellLogCurveCollection* rim3dWellLogCurveCollection() const;
const RimWellPathCompletions* completions() const;
RimFishbonesCollection* fishbonesCollection();
const RimFishbonesCollection* fishbonesCollection() const;
RimPerforationCollection* perforationIntervalCollection();
const RimPerforationCollection* perforationIntervalCollection() const;
RimWellPathFractureCollection* fractureCollection();
const RimWellPathFractureCollection* fractureCollection() const;
bool showWellPathLabel() const;
bool showWellPath() const;
cvf::Color3f wellPathColor() const;
void setWellPathColor(const cvf::Color3f& color );
double combinedScaleFactor() const;
double wellPathRadius(double characteristicCellSize) const;
double wellPathRadiusScaleFactor() const;
protected:
// Override PdmObject
virtual caf::PdmFieldHandle* userDescriptionField() override;
virtual caf::PdmFieldHandle* objectToggleField() override;
@ -89,56 +133,6 @@ public:
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;
virtual void initAfterRead() override;
QString name() const;
void setName(const QString& name);
std::vector<RimWellLogFile*> wellLogFiles() const;
caf::PdmField<QString> filepath;
caf::PdmField<int> wellPathIndexInFile; // -1 means none.
caf::PdmField<QString> m_simWellName;
caf::PdmField<int> m_branchIndex;
caf::PdmField<bool> showWellPathLabel;
caf::PdmField<bool> showWellPath;
caf::PdmField<cvf::Color3f> wellPathColor;
double wellPathRadius(double characteristicCellSize) const;
caf::PdmField<double> wellPathRadiusScaleFactor;
RimFishbonesCollection* fishbonesCollection();
const RimFishbonesCollection* fishbonesCollection() const;
RimPerforationCollection* perforationIntervalCollection();
const RimPerforationCollection* perforationIntervalCollection() const;
const RimWellPathCompletions* completions() const;
RimWellPathFractureCollection* fractureCollection();
const RimWellPathFractureCollection* fractureCollection() const;
RigWellPath* wellPathGeometry();
const RigWellPath* wellPathGeometry() const;
bool readWellPathFile(QString * errorMessage, RifWellPathImporter* wellPathImporter);
void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath);
double combinedScaleFactor() const;
void setUnitSystem(RiaEclipseUnitTools::UnitSystem unitSystem);
RiaEclipseUnitTools::UnitSystem unitSystem() const;
static RimWellPath* fromFilePath(QString filePath);
const QString associatedSimulationWellName() const;
int associatedSimulationWellBranch() const;
bool tryAssociateWithSimulationWell();
bool isAssociatedWithSimulationWell() const;
bool tryMatchName(QString wellPathName,
const std::vector<QString>& simWellNames,
std::function<QString(QString)> stringFormatter = nullptr);
private:
void setWellPathGeometry(RigWellPath* wellPathModel);
@ -157,29 +151,47 @@ private:
static size_t simulationWellBranchCount(const QString& simWellName);
private:
// Fields
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<int> m_branchIndex;
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<RiaEclipseUnitTools::UnitSystemType> m_unitSystem;
caf::PdmChildField<RimWellPathCompletions*> m_completions;
cvf::ref<RigWellPath> m_wellPath;
cvf::ref<RigWellPathFormations> m_wellPathFormations;
caf::PdmField<QString> m_name;
caf::PdmField<QString> m_wellPathFormationFilePath;
caf::PdmField<QString> m_formationKeyInFile;
caf::PdmChildArrayField<RimWellLogFile*> m_wellLogFiles;
caf::PdmField<cvf::Color3f> m_wellPathColor;
caf::PdmField<bool> m_showWellPath;
caf::PdmField<bool> m_showWellPathLabel;
caf::PdmField<double> m_wellPathRadiusScaleFactor;
caf::PdmChildArrayField<RimWellLogFile*> m_wellLogFiles;
caf::PdmChildField<Rim3dWellLogCurveCollection*> m_3dWellLogCurves;
caf::PdmChildField<RimWellPathCompletions*> m_completions;
// Geometry and data
cvf::ref<RigWellPath> m_wellPath;
cvf::ref<RigWellPathFormations> m_wellPathFormations;
// Obsolete fields
caf::PdmChildField<RimWellLogFile*> m_wellLogFile_OBSOLETE;
};

View File

@ -207,7 +207,7 @@ void RimWellPathCollection::addWellPaths( QStringList filePaths )
if (fi.suffix().compare("json") == 0)
{
RimWellPath* wellPath = new RimWellPath();
wellPath->filepath = filePath;
wellPath->setFilepath(filePath);
wellPathArray.push_back(wellPath);
}
else
@ -217,8 +217,8 @@ void RimWellPathCollection::addWellPaths( QStringList filePaths )
for (size_t i = 0; i < wellPathCount; ++i)
{
RimWellPath* wellPath = new RimWellPath();
wellPath->filepath = filePath;
wellPath->wellPathIndexInFile = static_cast<int>(i);
wellPath->setFilepath(filePath);
wellPath->setWellPathIndexInFile(static_cast<int>(i));
wellPathArray.push_back(wellPath);
}
}
@ -260,8 +260,8 @@ void RimWellPathCollection::readAndAddWellPaths(std::vector<RimWellPath*>& wellP
RimWellPath* existingWellPath = tryFindMatchingWellPath(wellPath->name());
if (existingWellPath)
{
existingWellPath->filepath = wellPath->filepath;
existingWellPath->wellPathIndexInFile = wellPath->wellPathIndexInFile;
existingWellPath->setFilepath(wellPath->filepath());
existingWellPath->setWellPathIndexInFile(wellPath->wellPathIndexInFile());
existingWellPath->readWellPathFile(nullptr, m_wellPathImporter);
// Let name from well path file override name from well log file
@ -272,7 +272,7 @@ void RimWellPathCollection::readAndAddWellPaths(std::vector<RimWellPath*>& wellP
}
else
{
wellPath->wellPathColor = cvf::Color3f(interpolatedWellColors[wpIdx]);
wellPath->setWellPathColor(cvf::Color3f(interpolatedWellColors[wpIdx]));
wellPath->setUnitSystem(findUnitSystemForWellPath(wellPath));
m_mostRecentlyUpdatedWellPath = wellPath;
wellPaths.push_back(wellPath);
@ -531,7 +531,7 @@ void RimWellPathCollection::removeWellPath(RimWellPath* wellPath)
bool isFilePathUsed = false;
for (size_t i = 0; i < wellPaths.size(); i++)
{
if (wellPaths[i]->filepath == wellPath->filepath)
if (wellPaths[i]->filepath() == wellPath->filepath())
{
isFilePathUsed = true;
break;
@ -542,7 +542,7 @@ void RimWellPathCollection::removeWellPath(RimWellPath* wellPath)
{
// One file can have multiple well paths
// If no other well paths are referencing the filepath, remove cached data from the file reader
m_wellPathImporter->removeFilePath(wellPath->filepath);
m_wellPathImporter->removeFilePath(wellPath->filepath());
}
}