2018-06-27 10:22:08 -05:00
|
|
|
#include "RimModeledWellPath.h"
|
|
|
|
#include "cafPdmUiTableViewEditor.h"
|
|
|
|
#include "RimWellPathTarget.h"
|
|
|
|
#include "cafPdmUiTreeOrdering.h"
|
|
|
|
#include "cafCmdFeatureMenuBuilder.h"
|
2018-07-02 07:51:17 -05:00
|
|
|
#include "RigWellPath.h"
|
|
|
|
#include "RimProject.h"
|
|
|
|
#include "cvfGeometryTools.h"
|
|
|
|
#include "cvfMatrix4.h"
|
|
|
|
|
|
|
|
#include "RiaPolyArcLineSampler.h"
|
2018-06-27 10:22:08 -05:00
|
|
|
|
2018-06-28 02:00:34 -05:00
|
|
|
CAF_PDM_SOURCE_INIT(RimModeledWellPath, "ModeledWellPath");
|
2018-06-27 10:22:08 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-06-28 02:00:34 -05:00
|
|
|
RimModeledWellPath::RimModeledWellPath()
|
2018-06-27 10:22:08 -05:00
|
|
|
{
|
|
|
|
CAF_PDM_InitObject("Modeled WellPath", ":/Well.png", "", "");
|
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault(&m_geometryDefinition, "WellPathGeometryDef", "Trajectory", "", "", "");
|
|
|
|
//m_geometryDefinition.uiCapability()->setUiHidden(true);
|
|
|
|
m_geometryDefinition = new RimWellPathGeometryDef;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-06-28 02:00:34 -05:00
|
|
|
RimModeledWellPath::~RimModeledWellPath()
|
2018-06-27 10:22:08 -05:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-07-02 07:51:17 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimModeledWellPath::updateWellPathVisualization()
|
|
|
|
{
|
|
|
|
this->setWellPathGeometry(m_geometryDefinition->createWellPathGeometry().p());
|
|
|
|
RimProject* proj;
|
|
|
|
this->firstAncestorOrThisOfTypeAsserted(proj);
|
|
|
|
proj->createDisplayModelAndRedrawAllViews();
|
|
|
|
}
|
|
|
|
|
2018-06-27 10:22:08 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-06-28 02:00:34 -05:00
|
|
|
void RimModeledWellPath::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName)
|
2018-06-27 10:22:08 -05:00
|
|
|
{
|
|
|
|
uiTreeOrdering.add(m_geometryDefinition());
|
|
|
|
RimWellPath::defineUiTreeOrdering(uiTreeOrdering, uiConfigName);
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace caf
|
|
|
|
{
|
|
|
|
template<>
|
|
|
|
void caf::AppEnum< RimWellPathGeometryDef::WellStartType >::setUp()
|
|
|
|
{
|
|
|
|
addItem(RimWellPathGeometryDef::START_AT_FIRST_TARGET, "START_AT_FIRST_TARGET", "Start at First Target");
|
|
|
|
addItem(RimWellPathGeometryDef::START_AT_SURFACE, "START_AT_SURFACE", "Start at Surface");
|
|
|
|
addItem(RimWellPathGeometryDef::START_FROM_OTHER_WELL, "START_FROM_OTHER_WELL", "Branch");
|
|
|
|
addItem(RimWellPathGeometryDef::START_AT_AUTO_SURFACE, "START_AT_AUTO_SURFACE", "Auto Surface");
|
|
|
|
|
|
|
|
setDefault(RimWellPathGeometryDef::START_AT_FIRST_TARGET);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CAF_PDM_SOURCE_INIT(RimWellPathGeometryDef, "WellPathGeometryDef");
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimWellPathGeometryDef::RimWellPathGeometryDef()
|
|
|
|
{
|
|
|
|
CAF_PDM_InitObject("Trajectory", ":/Well.png", "", "");
|
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault(&m_wellStartType, "WellStartType", "Start Type", "", "", "");
|
2018-07-02 07:51:17 -05:00
|
|
|
CAF_PDM_InitField(&m_referencePoint, "ReferencePos", cvf::Vec3d(0,0,0), "UTM Reference Point", "", "", "");
|
2018-06-27 10:22:08 -05:00
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault(&m_parentWell, "ParentWell", "Parent Well", "", "", "");
|
|
|
|
CAF_PDM_InitField(&m_kickoffDepthOrMD, "KickoffDepthOrMD", 100.0, "Kickoff Depth", "", "", "");
|
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault(&m_wellTargets, "WellPathTargets", "Well Targets", "", "", "");
|
|
|
|
m_wellTargets.uiCapability()->setUiEditorTypeName(caf::PdmUiTableViewEditor::uiEditorTypeName());
|
|
|
|
//m_wellTargets.uiCapability()->setUiTreeHidden(true);
|
|
|
|
m_wellTargets.uiCapability()->setUiTreeChildrenHidden(true);
|
|
|
|
m_wellTargets.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP);
|
|
|
|
m_wellTargets.uiCapability()->setCustomContextMenuEnabled(true);
|
|
|
|
|
|
|
|
|
|
|
|
m_wellTargets.push_back(new RimWellPathTarget());
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimWellPathGeometryDef::~RimWellPathGeometryDef()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-07-02 07:51:17 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
cvf::ref<RigWellPath> RimWellPathGeometryDef::createWellPathGeometry()
|
|
|
|
{
|
|
|
|
cvf::ref<RigWellPath> wellPathGeometry = new RigWellPath;
|
|
|
|
|
|
|
|
if (m_wellTargets.size() < 2) return wellPathGeometry;
|
|
|
|
|
|
|
|
RiaPolyArcLineSampler arcLineSampler(lineArcEndpoints());
|
|
|
|
|
|
|
|
arcLineSampler.sampledPointsAndMDs(30,
|
|
|
|
false,
|
|
|
|
&(wellPathGeometry->m_wellPathPoints),
|
|
|
|
&(wellPathGeometry->m_measuredDepths));
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
double md = 0.0;
|
|
|
|
wellPathGeometry->m_wellPathPoints.push_back(m_referencePoint() + m_wellTargets[0]->targetPointXYZ());
|
|
|
|
wellPathGeometry->m_measuredDepths.push_back(md);
|
|
|
|
|
|
|
|
for (size_t tIdx = 1; tIdx < m_wellTargets.size(); ++tIdx)
|
|
|
|
{
|
|
|
|
cvf::Vec3d p1 = wellPathGeometry->m_wellPathPoints.back();
|
|
|
|
RimWellPathTarget* target = m_wellTargets[tIdx];
|
|
|
|
wellPathGeometry->m_wellPathPoints.push_back(m_referencePoint() + target->targetPointXYZ());
|
|
|
|
cvf::Vec3d p2 = wellPathGeometry->m_wellPathPoints.back();
|
|
|
|
md += (p2 - p1).length();
|
|
|
|
wellPathGeometry->m_measuredDepths.push_back( md );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return wellPathGeometry;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellPathGeometryDef::updateWellPathVisualization()
|
|
|
|
{
|
|
|
|
RimModeledWellPath* modWellPath;
|
|
|
|
this->firstAncestorOrThisOfTypeAsserted(modWellPath);
|
|
|
|
modWellPath->updateWellPathVisualization();
|
|
|
|
}
|
|
|
|
|
2018-06-27 10:22:08 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellPathGeometryDef::insertTarget(RimWellPathTarget* targetToInsertBefore, RimWellPathTarget* targetToInsert)
|
|
|
|
{
|
|
|
|
size_t index = m_wellTargets.index(targetToInsertBefore);
|
|
|
|
if (index < m_wellTargets.size()) m_wellTargets.insert(index, targetToInsert);
|
|
|
|
else m_wellTargets.push_back(targetToInsert);
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellPathGeometryDef::deleteTarget(RimWellPathTarget* targetTodelete)
|
|
|
|
{
|
|
|
|
m_wellTargets.removeChildObject(targetTodelete);
|
|
|
|
delete targetTodelete;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-07-02 07:51:17 -05:00
|
|
|
void RimWellPathGeometryDef::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
|
|
|
|
const QVariant& oldValue,
|
|
|
|
const QVariant& newValue)
|
2018-06-27 10:22:08 -05:00
|
|
|
{
|
2018-07-02 07:51:17 -05:00
|
|
|
if (&m_referencePoint == changedField)
|
2018-06-27 10:22:08 -05:00
|
|
|
{
|
|
|
|
std::cout << "fieldChanged" << std::endl;
|
|
|
|
}
|
2018-07-02 07:51:17 -05:00
|
|
|
|
|
|
|
updateWellPathVisualization();
|
2018-06-27 10:22:08 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellPathGeometryDef::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
|
|
|
{
|
|
|
|
uiOrdering.add(&m_wellStartType);
|
|
|
|
if (m_wellStartType == START_FROM_OTHER_WELL)
|
|
|
|
{
|
|
|
|
uiOrdering.add(&m_parentWell);
|
|
|
|
m_kickoffDepthOrMD.uiCapability()->setUiName("Measured Depth");
|
|
|
|
uiOrdering.add(&m_kickoffDepthOrMD);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_wellStartType == START_AT_SURFACE)
|
|
|
|
{
|
2018-07-02 07:51:17 -05:00
|
|
|
m_kickoffDepthOrMD.uiCapability()->setUiName("Kick-Off Depth");
|
2018-06-27 10:22:08 -05:00
|
|
|
uiOrdering.add(&m_kickoffDepthOrMD);
|
|
|
|
}
|
|
|
|
|
2018-07-02 07:51:17 -05:00
|
|
|
uiOrdering.add(&m_referencePoint);
|
2018-06-27 10:22:08 -05:00
|
|
|
uiOrdering.add(&m_wellTargets);
|
|
|
|
uiOrdering.skipRemainingFields(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellPathGeometryDef::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName)
|
|
|
|
{
|
|
|
|
uiTreeOrdering.skipRemainingChildren(true);
|
|
|
|
}
|
|
|
|
|
2018-07-02 07:51:17 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<cvf::Vec3d> RimWellPathGeometryDef::lineArcEndpoints()
|
|
|
|
{
|
|
|
|
std::vector<cvf::Vec3d> endPoints;
|
|
|
|
for (RimWellPathTarget* target: m_wellTargets)
|
|
|
|
{
|
|
|
|
endPoints.push_back( target->targetPointXYZ() + m_referencePoint() );
|
|
|
|
}
|
|
|
|
|
|
|
|
return endPoints;
|
|
|
|
}
|
|
|
|
|
2018-06-27 10:22:08 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellPathGeometryDef::defineCustomContextMenu(const caf::PdmFieldHandle* fieldNeedingMenu,
|
|
|
|
QMenu* menu,
|
|
|
|
QWidget* fieldEditorWidget)
|
|
|
|
{
|
|
|
|
caf::CmdFeatureMenuBuilder menuBuilder;
|
|
|
|
|
|
|
|
menuBuilder << "RicNewWellPathListTargetFeature";
|
|
|
|
menuBuilder << "Separator";
|
|
|
|
menuBuilder << "RicDeleteWellPathTargetFeature";
|
|
|
|
|
|
|
|
menuBuilder.appendToMenu(menu);
|
|
|
|
}
|