From 1414751859be892624f7c5ebe7279701979257bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rnar=20Grip=20Fj=C3=A6r?= Date: Wed, 7 Jun 2017 11:57:25 +0200 Subject: [PATCH] #1573 Set unit system on well path --- ...NewFishbonesSubsAtMeasuredDepthFeature.cpp | 3 ++ .../RicNewFishbonesSubsFeature.cpp | 6 +++ .../RicEditPerforationCollectionFeature.cpp | 8 +++- ...forationIntervalAtMeasuredDepthFeature.cpp | 4 ++ .../RicNewPerforationIntervalFeature.cpp | 6 +++ .../WellPathCommands/CMakeLists_files.cmake | 4 ++ .../RicWellPathsUnitSystemSettingsImpl.cpp | 45 +++++++++++++++++++ .../RicWellPathsUnitSystemSettingsImpl.h | 32 +++++++++++++ .../RicWellPathsUnitSystemSettingsUi.cpp | 45 +++++++++++++++++++ .../RicWellPathsUnitSystemSettingsUi.h | 41 +++++++++++++++++ .../ProjectDataModel/RimUnitSystem.cpp | 7 +-- .../ProjectDataModel/RimUnitSystem.h | 7 ++- .../ProjectDataModel/RimWellPath.cpp | 20 +++++++++ .../ProjectDataModel/RimWellPath.h | 7 +++ .../RimWellPathCollection.cpp | 45 ++++++++++++++++++- .../ProjectDataModel/RimWellPathCollection.h | 4 ++ 16 files changed, 278 insertions(+), 6 deletions(-) create mode 100644 ApplicationCode/Commands/WellPathCommands/RicWellPathsUnitSystemSettingsImpl.cpp create mode 100644 ApplicationCode/Commands/WellPathCommands/RicWellPathsUnitSystemSettingsImpl.h create mode 100644 ApplicationCode/Commands/WellPathCommands/RicWellPathsUnitSystemSettingsUi.cpp create mode 100644 ApplicationCode/Commands/WellPathCommands/RicWellPathsUnitSystemSettingsUi.h diff --git a/ApplicationCode/Commands/CompletionCommands/RicNewFishbonesSubsAtMeasuredDepthFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicNewFishbonesSubsAtMeasuredDepthFeature.cpp index d91ce7f5b8..66979aba10 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicNewFishbonesSubsAtMeasuredDepthFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicNewFishbonesSubsAtMeasuredDepthFeature.cpp @@ -19,6 +19,7 @@ #include "RicNewFishbonesSubsAtMeasuredDepthFeature.h" #include "RicNewFishbonesSubsFeature.h" +#include "WellPathCommands/RicWellPathsUnitSystemSettingsImpl.h" #include "RimFishbonesCollection.h" #include "RimFishbonesMultipleSubs.h" @@ -45,6 +46,8 @@ void RicNewFishbonesSubsAtMeasuredDepthFeature::onActionTriggered(bool isChecked RimWellPath* wellPath = wellPathSelItem->m_wellpath; CVF_ASSERT(wellPath); + + if (!RicWellPathsUnitSystemSettingsImpl::ensureHasUnitSystem(wellPath)) return; RimFishbonesMultipleSubs* obj = new RimFishbonesMultipleSubs; wellPath->fishbonesCollection()->appendFishbonesSubs(obj); diff --git a/ApplicationCode/Commands/CompletionCommands/RicNewFishbonesSubsFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicNewFishbonesSubsFeature.cpp index 22a77e6885..0243bf54df 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicNewFishbonesSubsFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicNewFishbonesSubsFeature.cpp @@ -18,6 +18,8 @@ #include "RicNewFishbonesSubsFeature.h" +#include "WellPathCommands/RicWellPathsUnitSystemSettingsImpl.h" + #include "RiaApplication.h" #include "RimProject.h" @@ -45,6 +47,10 @@ void RicNewFishbonesSubsFeature::onActionTriggered(bool isChecked) RimFishbonesCollection* fishbonesCollection = selectedFishbonesCollection(); CVF_ASSERT(fishbonesCollection); + RimWellPath* wellPath; + fishbonesCollection->firstAncestorOrThisOfTypeAsserted(wellPath); + if (!RicWellPathsUnitSystemSettingsImpl::ensureHasUnitSystem(wellPath)) return; + RimFishbonesMultipleSubs* obj = new RimFishbonesMultipleSubs; obj->setName(QString("Fishbones Subs (%1)").arg(fishbonesCollection->fishbonesSubs.size())); fishbonesCollection->appendFishbonesSubs(obj); diff --git a/ApplicationCode/Commands/PerforationCommands/RicEditPerforationCollectionFeature.cpp b/ApplicationCode/Commands/PerforationCommands/RicEditPerforationCollectionFeature.cpp index 018b3f4ffb..f9e0f51c00 100644 --- a/ApplicationCode/Commands/PerforationCommands/RicEditPerforationCollectionFeature.cpp +++ b/ApplicationCode/Commands/PerforationCommands/RicEditPerforationCollectionFeature.cpp @@ -18,6 +18,8 @@ #include "RicEditPerforationCollectionFeature.h" +#include "WellPathCommands/RicWellPathsUnitSystemSettingsImpl.h" + #include "RiuEditPerforationCollectionWidget.h" #include "RimPerforationCollection.h" @@ -46,9 +48,13 @@ void RicEditPerforationCollectionFeature::onActionTriggered(bool isChecked) this->disableModelChangeContribution(); RimPerforationCollection* perforationCollection = selectedPerforationCollection(); - + if (perforationCollection == nullptr) return; + RimWellPath* wellPath; + perforationCollection->firstAncestorOrThisOfTypeAsserted(wellPath); + if (!RicWellPathsUnitSystemSettingsImpl::ensureHasUnitSystem(wellPath)) return; + RiuEditPerforationCollectionWidget dlg(nullptr, perforationCollection); dlg.exec(); diff --git a/ApplicationCode/Commands/PerforationCommands/RicNewPerforationIntervalAtMeasuredDepthFeature.cpp b/ApplicationCode/Commands/PerforationCommands/RicNewPerforationIntervalAtMeasuredDepthFeature.cpp index e29b86ff44..ad5f91a9c2 100644 --- a/ApplicationCode/Commands/PerforationCommands/RicNewPerforationIntervalAtMeasuredDepthFeature.cpp +++ b/ApplicationCode/Commands/PerforationCommands/RicNewPerforationIntervalAtMeasuredDepthFeature.cpp @@ -18,6 +18,8 @@ #include "RicNewPerforationIntervalAtMeasuredDepthFeature.h" +#include "WellPathCommands/RicWellPathsUnitSystemSettingsImpl.h" + #include "RimFishbonesMultipleSubs.h" #include "RimPerforationCollection.h" #include "RimPerforationInterval.h" @@ -45,6 +47,8 @@ void RicNewPerforationIntervalAtMeasuredDepthFeature::onActionTriggered(bool isC RimWellPath* wellPath = wellPathSelItem->m_wellpath; CVF_ASSERT(wellPath); + + if (!RicWellPathsUnitSystemSettingsImpl::ensureHasUnitSystem(wellPath)) return; RimPerforationInterval* perforationInterval = new RimPerforationInterval; int measuredDepth = wellPathSelItem->m_measuredDepth; diff --git a/ApplicationCode/Commands/PerforationCommands/RicNewPerforationIntervalFeature.cpp b/ApplicationCode/Commands/PerforationCommands/RicNewPerforationIntervalFeature.cpp index bbf4a6b184..f20bd0db70 100644 --- a/ApplicationCode/Commands/PerforationCommands/RicNewPerforationIntervalFeature.cpp +++ b/ApplicationCode/Commands/PerforationCommands/RicNewPerforationIntervalFeature.cpp @@ -19,6 +19,8 @@ #include "RicNewPerforationIntervalFeature.h" +#include "WellPathCommands/RicWellPathsUnitSystemSettingsImpl.h" + #include "RiuMainWindow.h" #include "RimPerforationInterval.h" @@ -49,6 +51,10 @@ void RicNewPerforationIntervalFeature::onActionTriggered(bool isChecked) RimPerforationCollection* perforationCollection = selectedPerforationCollection(); if (perforationCollection == nullptr) return; + RimWellPath* wellPath; + perforationCollection->firstAncestorOrThisOfTypeAsserted(wellPath); + if (!RicWellPathsUnitSystemSettingsImpl::ensureHasUnitSystem(wellPath)) return; + RimPerforationInterval* perforationInterval = new RimPerforationInterval; perforationCollection->appendPerforation(perforationInterval); diff --git a/ApplicationCode/Commands/WellPathCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/WellPathCommands/CMakeLists_files.cmake index b249623bc5..0cf3de913c 100644 --- a/ApplicationCode/Commands/WellPathCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/WellPathCommands/CMakeLists_files.cmake @@ -8,6 +8,8 @@ set (SOURCE_GROUP_HEADER_FILES ${CEE_CURRENT_LIST_DIR}RicWellPathDeleteFeature.h ${CEE_CURRENT_LIST_DIR}RicWellPathsImportFileFeature.h ${CEE_CURRENT_LIST_DIR}RicWellPathsImportSsihubFeature.h +${CEE_CURRENT_LIST_DIR}RicWellPathsUnitSystemSettingsImpl.h +${CEE_CURRENT_LIST_DIR}RicWellPathsUnitSystemSettingsUi.h ${CEE_CURRENT_LIST_DIR}RicWellPathViewerEventHandler.h ) @@ -15,6 +17,8 @@ set (SOURCE_GROUP_SOURCE_FILES ${CEE_CURRENT_LIST_DIR}RicWellPathDeleteFeature.cpp ${CEE_CURRENT_LIST_DIR}RicWellPathsImportFileFeature.cpp ${CEE_CURRENT_LIST_DIR}RicWellPathsImportSsihubFeature.cpp +${CEE_CURRENT_LIST_DIR}RicWellPathsUnitSystemSettingsImpl.cpp +${CEE_CURRENT_LIST_DIR}RicWellPathsUnitSystemSettingsUi.cpp ${CEE_CURRENT_LIST_DIR}RicWellPathViewerEventHandler.cpp ) diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathsUnitSystemSettingsImpl.cpp b/ApplicationCode/Commands/WellPathCommands/RicWellPathsUnitSystemSettingsImpl.cpp new file mode 100644 index 0000000000..ef7f1535a1 --- /dev/null +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathsUnitSystemSettingsImpl.cpp @@ -0,0 +1,45 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicWellPathsUnitSystemSettingsImpl.h" + +#include "RicWellPathsUnitSystemSettingsUi.h" + +#include "RiuMainWindow.h" + +#include "cafPdmUiPropertyViewDialog.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicWellPathsUnitSystemSettingsImpl::ensureHasUnitSystem(RimWellPath * wellPath) +{ + if (wellPath->unitSystem() != RimUnitSystem::UNITS_UNKNOWN) + { + return true; + } + + RicWellPathsUnitSystemSettingsUi settings; + caf::PdmUiPropertyViewDialog propertyDialog(RiuMainWindow::instance(), &settings, "Select Unit System for Well Path", ""); + if (propertyDialog.exec() == QDialog::Accepted) + { + wellPath->setUnitSystem(settings.unitSystem()); + return true; + } + return false; +} diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathsUnitSystemSettingsImpl.h b/ApplicationCode/Commands/WellPathCommands/RicWellPathsUnitSystemSettingsImpl.h new file mode 100644 index 0000000000..d736ea4d8e --- /dev/null +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathsUnitSystemSettingsImpl.h @@ -0,0 +1,32 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RimUnitSystem.h" +#include "RimWellPath.h" + +//================================================================================================== +/// +/// +//================================================================================================== +class RicWellPathsUnitSystemSettingsImpl +{ +public: + static bool ensureHasUnitSystem(RimWellPath* wellPath); +}; diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathsUnitSystemSettingsUi.cpp b/ApplicationCode/Commands/WellPathCommands/RicWellPathsUnitSystemSettingsUi.cpp new file mode 100644 index 0000000000..b0b171366d --- /dev/null +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathsUnitSystemSettingsUi.cpp @@ -0,0 +1,45 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicWellPathsUnitSystemSettingsUi.h" + +CAF_PDM_SOURCE_INIT(RicWellPathsUnitSystemSettingsUi, "RicWellPathsUnitSystemSettingsUi"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicWellPathsUnitSystemSettingsUi::RicWellPathsUnitSystemSettingsUi() +{ + CAF_PDM_InitObject("RimWellPathsUnitSystemSettings", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&unitSystem, "UnitSystem", "Unit System", "", "", ""); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RicWellPathsUnitSystemSettingsUi::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) +{ + QList options; + if (fieldNeedingOptions == &unitSystem) + { + options.push_back(caf::PdmOptionItemInfo(RimUnitSystem::UnitSystemType::uiText(RimUnitSystem::UNITS_METRIC), RimUnitSystem::UNITS_METRIC)); + options.push_back(caf::PdmOptionItemInfo(RimUnitSystem::UnitSystemType::uiText(RimUnitSystem::UNITS_FIELD), RimUnitSystem::UNITS_FIELD)); + } + return options; +} diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathsUnitSystemSettingsUi.h b/ApplicationCode/Commands/WellPathCommands/RicWellPathsUnitSystemSettingsUi.h new file mode 100644 index 0000000000..8cecafbb04 --- /dev/null +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathsUnitSystemSettingsUi.h @@ -0,0 +1,41 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RimUnitSystem.h" + +#include "cafPdmObject.h" +#include "cafPdmField.h" + +//================================================================================================== +/// +/// +//================================================================================================== +class RicWellPathsUnitSystemSettingsUi : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; +public: + + RicWellPathsUnitSystemSettingsUi(); + + caf::PdmField unitSystem; + +protected: + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; +}; diff --git a/ApplicationCode/ProjectDataModel/RimUnitSystem.cpp b/ApplicationCode/ProjectDataModel/RimUnitSystem.cpp index d7d859539d..dda9acf2d5 100644 --- a/ApplicationCode/ProjectDataModel/RimUnitSystem.cpp +++ b/ApplicationCode/ProjectDataModel/RimUnitSystem.cpp @@ -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); } diff --git a/ApplicationCode/ProjectDataModel/RimUnitSystem.h b/ApplicationCode/ProjectDataModel/RimUnitSystem.h index c984b05a7e..d8a63e23a8 100644 --- a/ApplicationCode/ProjectDataModel/RimUnitSystem.h +++ b/ApplicationCode/ProjectDataModel/RimUnitSystem.h @@ -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; } diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.cpp b/ApplicationCode/ProjectDataModel/RimWellPath.cpp index 82cc77847e..9138c62fad 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPath.cpp @@ -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(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.h b/ApplicationCode/ProjectDataModel/RimWellPath.h index 39557b1bed..44d3034fd8 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.h +++ b/ApplicationCode/ProjectDataModel/RimWellPath.h @@ -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 m_surveyType; caf::PdmField m_datumElevation; + + caf::PdmField m_unitSystem; caf::PdmChildField m_completions; diff --git a/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp b/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp index 6b748ce561..4db6c6bcbd 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp @@ -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 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& 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& w1, const caf::PdmPointer& 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; +} diff --git a/ApplicationCode/ProjectDataModel/RimWellPathCollection.h b/ApplicationCode/ProjectDataModel/RimWellPathCollection.h index b6281759de..a9d4bfdab8 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathCollection.h +++ b/ApplicationCode/ProjectDataModel/RimWellPathCollection.h @@ -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& wellPathArray); void sortWellsByName(); + RimUnitSystem::UnitSystemType findUnitSystemForWellPath(const RimWellPath* wellPath); + cvf::ref m_wellPathCollectionPartManager; RifWellPathImporter* m_wellPathImporter;