#1573 Set unit system on well path

This commit is contained in:
Bjørnar Grip Fjær
2017-06-07 11:57:25 +02:00
parent ac447c0486
commit 1414751859
16 changed files with 278 additions and 6 deletions

View File

@@ -25,10 +25,15 @@
#include "RiaColorTables.h"
#include "RigWellPath.h"
#include "RigEclipseCaseData.h"
#include "RigMainGrid.h"
#include "RimProject.h"
#include "RimWellLogFile.h"
#include "RimWellPath.h"
#include "RimOilField.h"
#include "RimEclipseCase.h"
#include "RimEclipseCaseCollection.h"
#include "RiuMainWindow.h"
@@ -168,7 +173,7 @@ void RimWellPathCollection::addWellPaths( QStringList filePaths )
{
std::vector<RimWellPath*> wellPathArray;
foreach (QString filePath, filePaths)
for (QString filePath : filePaths)
{
// Check if this file is already open
bool alreadyOpen = false;
@@ -257,6 +262,7 @@ void RimWellPathCollection::readAndAddWellPaths(std::vector<RimWellPath*>& wellP
else
{
wellPath->wellPathColor = cvf::Color3f(interpolatedWellColors[wpIdx]);
wellPath->setUnitSystem(findUnitSystemForWellPath(wellPath));
wellPaths.push_back(wellPath);
}
@@ -390,6 +396,9 @@ void RimWellPathCollection::removeWellPath(RimWellPath* wellPath)
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool lessWellPath(const caf::PdmPointer<RimWellPath>& w1, const caf::PdmPointer<RimWellPath>& w2)
{
if (w1.notNull() && w2.notNull())
@@ -407,3 +416,37 @@ void RimWellPathCollection::sortWellsByName()
{
std::sort(wellPaths.begin(), wellPaths.end(), lessWellPath);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimUnitSystem::UnitSystemType RimWellPathCollection::findUnitSystemForWellPath(const RimWellPath* wellPath)
{
RimProject* project;
firstAncestorOrThisOfTypeAsserted(project);
if (project->activeOilField()->analysisModels->cases.empty())
{
return RimUnitSystem::UNITS_UNKNOWN;
}
const RigEclipseCaseData* eclipseCaseData = project->activeOilField()->analysisModels->cases()[0]->eclipseCaseData();
cvf::BoundingBox caseBoundingBox = eclipseCaseData->mainGrid()->boundingBox();
cvf::BoundingBox wellPathBoundingBox;
for (auto& wellPathPoint : wellPath->wellPathGeometry()->m_wellPathPoints)
{
wellPathBoundingBox.add(wellPathPoint);
}
if (caseBoundingBox.intersects(wellPathBoundingBox))
{
if (eclipseCaseData->unitsType() == RigEclipseCaseData::UNITS_FIELD)
{
return RimUnitSystem::UNITS_FIELD;
}
else if (eclipseCaseData->unitsType() == RigEclipseCaseData::UNITS_METRIC)
{
return RimUnitSystem::UNITS_METRIC;
}
}
return RimUnitSystem::UNITS_UNKNOWN;
}