mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1573 Set unit system on well path
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user