Search for Eclipse data in project file folder in addition to the given case folder.

This allows for copy of a folder containing a project file and related Eclipse data
p4#: 20437
This commit is contained in:
Magne Sjaastad 2013-02-11 08:16:51 +01:00
parent cdd5997f76
commit 942cccfdcb
2 changed files with 46 additions and 11 deletions

View File

@ -25,6 +25,7 @@
#include "RifReaderMockModel.h"
#include "RifReaderEclipseInput.h"
#include "cafProgressInfo.h"
#include "RimProject.h"
CAF_PDM_SOURCE_INIT(RimResultReservoir, "EclipseCase");
@ -82,19 +83,11 @@ bool RimResultReservoir::openEclipseGridFile()
}
else
{
QString fullCaseName = caseName + ".EGRID";
QDir dir(caseDirectory.v());
if (!dir.exists(fullCaseName))
{
fullCaseName = caseName + ".GRID";
if (!dir.exists(fullCaseName))
QString fname = createAbsoluteFilenameFromCase(caseName);
if (fname.isEmpty())
{
return false;
}
}
QString fname = dir.absoluteFilePath(fullCaseName);
RigReservoir* reservoir = new RigReservoir;
readerInterface = new RifReaderEclipseOutput;
@ -213,3 +206,43 @@ QString RimResultReservoir::locationOnDisc() const
return caseDirectory;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimResultReservoir::createAbsoluteFilenameFromCase(const QString& caseName)
{
QString candidate;
candidate = QDir::fromNativeSeparators(caseDirectory.v() + QDir::separator() + caseName + ".EGRID");
if (QFile::exists(candidate)) return candidate;
candidate = QDir::fromNativeSeparators(caseDirectory.v() + QDir::separator() + caseName + ".GRID");
if (QFile::exists(candidate)) return candidate;
std::vector<caf::PdmObject*> parentObjects;
this->parentObjects(parentObjects);
QString projectPath;
for (size_t i = 0; i < parentObjects.size(); i++)
{
caf::PdmObject* obj = parentObjects[i];
RimProject* proj = dynamic_cast<RimProject*>(obj);
if (proj)
{
QFileInfo fi(proj->fileName);
projectPath = fi.path();
}
}
if (!projectPath.isEmpty())
{
candidate = QDir::fromNativeSeparators(projectPath + QDir::separator() + caseName + ".EGRID");
if (QFile::exists(candidate)) return candidate;
candidate = QDir::fromNativeSeparators(projectPath + QDir::separator() + caseName + ".GRID");
if (QFile::exists(candidate)) return candidate;
}
return QString();
}

View File

@ -53,4 +53,6 @@ public:
private:
cvf::ref<RifReaderInterface> createMockModel(QString modelName);
QString createAbsoluteFilenameFromCase(const QString& caseName);
};