(#605) Fixed delete of well path to avoid reuse of old data

This commit is contained in:
Magne Sjaastad
2015-10-29 13:12:55 +01:00
parent f004752aea
commit 1156da7f03
9 changed files with 202 additions and 19 deletions

View File

@@ -21,8 +21,8 @@ TEST(RimWellPathAsciiFileReaderTest, TestWellNameNoColon)
out << "1 2 3";
}
RimWellPathAsciiFileReader reader;
RimWellPathAsciiFileReader::WellData wpData = reader.readWellData(file.fileName(), 0);
RifWellPathAsciiFileReader reader;
RifWellPathAsciiFileReader::WellData wpData = reader.readWellData(file.fileName(), 0);
EXPECT_TRUE(wpData.m_name == wellName);
}
}
@@ -42,8 +42,8 @@ TEST(RimWellPathAsciiFileReaderTest, TestWellNameWithColon)
out << "1 2 3";
}
RimWellPathAsciiFileReader reader;
RimWellPathAsciiFileReader::WellData wpData = reader.readWellData(file.fileName(), 0);
RifWellPathAsciiFileReader reader;
RifWellPathAsciiFileReader::WellData wpData = reader.readWellData(file.fileName(), 0);
EXPECT_TRUE(wpData.m_name == wellName);
}
}
@@ -63,8 +63,8 @@ TEST(RimWellPathAsciiFileReaderTest, TestWellNameWithColonAndSpace)
out << "1 2 3";
}
RimWellPathAsciiFileReader reader;
RimWellPathAsciiFileReader::WellData wpData = reader.readWellData(file.fileName(), 0);
RifWellPathAsciiFileReader reader;
RifWellPathAsciiFileReader::WellData wpData = reader.readWellData(file.fileName(), 0);
EXPECT_TRUE(wpData.m_name == wellName);
}
}

View File

@@ -779,7 +779,7 @@ void RimProject::actionsBasedOnSelection(QMenu& contextMenu)
{
commandIds << "RicNewWellLogFileCurveFeature";
commandIds << "RicNewWellLogCurveExtractionFeature";
commandIds << "RicDeleteItemFeature";
commandIds << "RicWellPathDeleteFeature";
}
else if (dynamic_cast<RimCalcScript*>(uiItem))
{

View File

@@ -257,7 +257,7 @@ void RimWellPath::readJsonWellPathFile()
//--------------------------------------------------------------------------------------------------
void RimWellPath::readAsciiWellPathFile()
{
RimWellPathAsciiFileReader::WellData wpData = m_wellPathCollection->asciiFileReader()->readWellData(filepath(), wellPathIndexInFile());
RifWellPathAsciiFileReader::WellData wpData = m_wellPathCollection->asciiFileReader()->readWellData(filepath(), wellPathIndexInFile());
this->name = wpData.m_name;
setWellPathGeometry(wpData.m_wellPathGeometry.p());

View File

@@ -84,7 +84,7 @@ RimWellPathCollection::RimWellPathCollection()
m_wellPathCollectionPartManager = new RivWellPathCollectionPartMgr(this);
m_project = NULL;
m_asciiFileReader = new RimWellPathAsciiFileReader;
m_asciiFileReader = new RifWellPathAsciiFileReader;
}
@@ -349,7 +349,42 @@ RimWellPath* RimWellPathCollection::wellPathByName(const QString& wellPathName)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathAsciiFileReader::readAllWellData(QString filePath)
void RimWellPathCollection::deleteAllWellPaths()
{
wellPaths.deleteAllChildObjects();
m_asciiFileReader->clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathCollection::removeWellPath(RimWellPath* wellPath)
{
wellPaths.removeChildObject(wellPath);
bool isFilePathUsed = false;
for (size_t i = 0; i < wellPaths.size(); i++)
{
if (wellPaths[i]->filepath == wellPath->filepath)
{
isFilePathUsed = true;
break;
}
}
if (!isFilePathUsed)
{
// One file can have multiple well paths
// If no other well paths are referencing the filepath, remove cached data from the file reader
m_asciiFileReader->removeFilePath(wellPath->filepath);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifWellPathAsciiFileReader::readAllWellData(QString filePath)
{
std::map<QString, std::vector<WellData> >::iterator it = m_fileNameToWellDataGroupMap.find(filePath);
@@ -459,7 +494,7 @@ void RimWellPathAsciiFileReader::readAllWellData(QString filePath)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellPathAsciiFileReader::WellData RimWellPathAsciiFileReader::readWellData(QString filePath, int indexInFile)
RifWellPathAsciiFileReader::WellData RifWellPathAsciiFileReader::readWellData(QString filePath, int indexInFile)
{
this->readAllWellData(filePath);
@@ -473,7 +508,7 @@ RimWellPathAsciiFileReader::WellData RimWellPathAsciiFileReader::readWellData(QS
}
else
{
// Error : The ascii well path file does not contain that many wellpaths
// Error : The ascii well path file does not contain that many well paths
return WellData();
}
}
@@ -481,7 +516,7 @@ RimWellPathAsciiFileReader::WellData RimWellPathAsciiFileReader::readWellData(QS
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RimWellPathAsciiFileReader::wellDataCount(QString filePath)
size_t RifWellPathAsciiFileReader::wellDataCount(QString filePath)
{
std::map<QString, std::vector<WellData> >::iterator it = m_fileNameToWellDataGroupMap.find(filePath);
@@ -497,3 +532,19 @@ size_t RimWellPathAsciiFileReader::wellDataCount(QString filePath)
return it->second.size();;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifWellPathAsciiFileReader::clear()
{
m_fileNameToWellDataGroupMap.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifWellPathAsciiFileReader::removeFilePath(const QString& filePath)
{
m_fileNameToWellDataGroupMap.erase(filePath);
}

View File

@@ -34,7 +34,7 @@
#include <QString>
class RivWellPathCollectionPartMgr;
class RimWellPathAsciiFileReader;
class RifWellPathAsciiFileReader;
class RimWellPath;
class RimProject;
class RigWellPath;
@@ -80,7 +80,11 @@ public:
void readWellPathFiles();
void addWellPaths(QStringList filePaths);
RimWellPathAsciiFileReader* asciiFileReader() {return m_asciiFileReader;}
void removeWellPath(RimWellPath* wellPath);
void deleteAllWellPaths();
RifWellPathAsciiFileReader* asciiFileReader() {return m_asciiFileReader;}
RimWellPath* wellPathByName(const QString& wellPathName) const;
void addWellLogs(const QStringList& filePaths);
@@ -99,7 +103,7 @@ private:
caf::PdmPointer<RimProject> m_project;
cvf::ref<RivWellPathCollectionPartMgr> m_wellPathCollectionPartManager;
RimWellPathAsciiFileReader* m_asciiFileReader;
RifWellPathAsciiFileReader* m_asciiFileReader;
};
@@ -107,7 +111,7 @@ private:
///
///
//==================================================================================================
class RimWellPathAsciiFileReader
class RifWellPathAsciiFileReader
{
public:
struct WellData
@@ -119,8 +123,10 @@ public:
WellData readWellData(QString filePath, int indexInFile);
size_t wellDataCount(QString filePath);
private:
void clear();
void removeFilePath(const QString& filePath);
private:
void readAllWellData(QString filePath);
std::map<QString, std::vector<WellData> > m_fileNameToWellDataGroupMap;