#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

@ -19,6 +19,7 @@
#include "RicNewFishbonesSubsAtMeasuredDepthFeature.h"
#include "RicNewFishbonesSubsFeature.h"
#include "WellPathCommands/RicWellPathsUnitSystemSettingsImpl.h"
#include "RimFishbonesCollection.h"
#include "RimFishbonesMultipleSubs.h"
@ -46,6 +47,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);

View File

@ -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);

View File

@ -18,6 +18,8 @@
#include "RicEditPerforationCollectionFeature.h"
#include "WellPathCommands/RicWellPathsUnitSystemSettingsImpl.h"
#include "RiuEditPerforationCollectionWidget.h"
#include "RimPerforationCollection.h"
@ -49,6 +51,10 @@ void RicEditPerforationCollectionFeature::onActionTriggered(bool isChecked)
if (perforationCollection == nullptr) return;
RimWellPath* wellPath;
perforationCollection->firstAncestorOrThisOfTypeAsserted(wellPath);
if (!RicWellPathsUnitSystemSettingsImpl::ensureHasUnitSystem(wellPath)) return;
RiuEditPerforationCollectionWidget dlg(nullptr, perforationCollection);
dlg.exec();

View File

@ -18,6 +18,8 @@
#include "RicNewPerforationIntervalAtMeasuredDepthFeature.h"
#include "WellPathCommands/RicWellPathsUnitSystemSettingsImpl.h"
#include "RimFishbonesMultipleSubs.h"
#include "RimPerforationCollection.h"
#include "RimPerforationInterval.h"
@ -46,6 +48,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;
perforationInterval->setStartAndEndMD(measuredDepth, measuredDepth + 50);

View File

@ -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);

View File

@ -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
)

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// 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;
}

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RimUnitSystem.h"
#include "RimWellPath.h"
//==================================================================================================
///
///
//==================================================================================================
class RicWellPathsUnitSystemSettingsImpl
{
public:
static bool ensureHasUnitSystem(RimWellPath* wellPath);
};

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// 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<caf::PdmOptionItemInfo> RicWellPathsUnitSystemSettingsUi::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly)
{
QList<caf::PdmOptionItemInfo> 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;
}

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// 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<RimUnitSystem::UnitSystemType> unitSystem;
protected:
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;
};

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_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);
@ -112,6 +117,8 @@ private:
caf::PdmField<QString> m_surveyType;
caf::PdmField<double> m_datumElevation;
caf::PdmField<RimUnitSystem::UnitSystemType> m_unitSystem;
caf::PdmChildField<RimWellPathCompletions*> m_completions;
cvf::ref<RigWellPath> m_wellPath;

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;