#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

@@ -23,10 +23,11 @@
namespace caf
{
template<>
void caf::AppEnum< RimUnitSystem::UnitSystem >::setUp()
void RimUnitSystem::UnitSystemType::setUp()
{
addItem(RimUnitSystem::UNITS_METRIC, "UNITS_METRIC", "Metric");
addItem(RimUnitSystem::UNITS_FIELD, "UNITS_FIELD", "Field");
addItem(RimUnitSystem::UNITS_METRIC, "UNITS_METRIC", "Metric");
addItem(RimUnitSystem::UNITS_FIELD, "UNITS_FIELD", "Field");
addItem(RimUnitSystem::UNITS_UNKNOWN, "UNITS_UNKNOWN", "Unknown");
setDefault(RimUnitSystem::UNITS_METRIC);
}

View File

@@ -18,6 +18,8 @@
#pragma once
#include "cafAppEnum.h"
class RimUnitSystem
{
@@ -25,10 +27,13 @@ public:
enum UnitSystem
{
UNITS_METRIC,
UNITS_FIELD
UNITS_FIELD,
UNITS_UNKNOWN,
//UNITS_LAB
};
typedef caf::AppEnum< RimUnitSystem::UnitSystem > UnitSystemType;
static double feetPerMeter() { return 3.2808399; }
static double meterPerFeet() { return 0.3048000; }

View File

@@ -90,6 +90,9 @@ RimWellPath::RimWellPath()
m_datumElevation.xmlCapability()->setIOWritable(false);
m_datumElevation.xmlCapability()->setIOReadable(false);
CAF_PDM_InitFieldNoDefault(&m_unitSystem, "UnitSystem", "Unit System", "", "", "");
m_unitSystem.uiCapability()->setUiReadOnly(true);
CAF_PDM_InitField(&filepath, "WellPathFilepath", QString(""), "Filepath", "", "", "");
filepath.uiCapability()->setUiReadOnly(true);
CAF_PDM_InitField(&wellPathIndexInFile, "WellPathNumberInFile", -1, "Well Number in file", "", "", "");
@@ -318,6 +321,7 @@ void RimWellPath::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiO
ssihubGroup->add(&updateUser);
ssihubGroup->add(&m_surveyType);
ssihubGroup->add(&m_datumElevation);
ssihubGroup->add(&m_unitSystem);
if (m_wellPath.notNull() && m_wellPath->hasDatumElevation())
{
@@ -444,6 +448,22 @@ double RimWellPath::combinedScaleFactor() const
return this->wellPathRadiusScaleFactor() * wellPathColl->wellPathRadiusScaleFactor();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPath::setUnitSystem(RimUnitSystem::UnitSystem unitSystem)
{
m_unitSystem = unitSystem;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimUnitSystem::UnitSystem RimWellPath::unitSystem() const
{
return m_unitSystem();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -20,6 +20,8 @@
#pragma once
#include "RimUnitSystem.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmPointer.h"
@@ -89,6 +91,9 @@ public:
double combinedScaleFactor() const;
void setUnitSystem(RimUnitSystem::UnitSystem unitSystem);
RimUnitSystem::UnitSystem unitSystem() const;
private:
void setWellPathGeometry(RigWellPath* wellPathModel);
@@ -111,6 +116,8 @@ private:
caf::PdmField<QString> m_surveyType;
caf::PdmField<double> m_datumElevation;
caf::PdmField<RimUnitSystem::UnitSystemType> m_unitSystem;
caf::PdmChildField<RimWellPathCompletions*> m_completions;

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;
}

View File

@@ -20,6 +20,8 @@
#pragma once
#include "RimUnitSystem.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
@@ -100,6 +102,8 @@ private:
void readAndAddWellPaths(std::vector<RimWellPath*>& wellPathArray);
void sortWellsByName();
RimUnitSystem::UnitSystemType findUnitSystemForWellPath(const RimWellPath* wellPath);
cvf::ref<RivWellPathCollectionPartMgr> m_wellPathCollectionPartManager;
RifWellPathImporter* m_wellPathImporter;