#2609 Move RimWellPathGeomDef to a separate file

This commit is contained in:
Jacob Støren 2018-07-03 08:42:31 +02:00
parent cbacd73068
commit 228b4a5f85
7 changed files with 306 additions and 239 deletions

View File

@ -19,9 +19,10 @@
CAF_CMD_SOURCE_INIT(RicDeleteWellPathTargetFeature, "RicDeleteWellPathTargetFeature");
#include "cafSelectionManager.h"
#include "RimWellPathGeometryDef.h"
#include "RimWellPathTarget.h"
#include "RimModeledWellPath.h"
#include "cafSelectionManager.h"
#include <QAction>
//--------------------------------------------------------------------------------------------------

View File

@ -19,9 +19,10 @@
CAF_CMD_SOURCE_INIT(RicNewWellPathListTargetFeature, "RicNewWellPathListTargetFeature");
#include "cafSelectionManager.h"
#include "RimWellPathGeometryDef.h"
#include "RimWellPathTarget.h"
#include "RimModeledWellPath.h"
#include "cafSelectionManager.h"
#include <QAction>
//--------------------------------------------------------------------------------------------------

View File

@ -26,6 +26,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimSimWellInViewCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimWellPath.h
${CMAKE_CURRENT_LIST_DIR}/RimFileWellPath.h
${CMAKE_CURRENT_LIST_DIR}/RimModeledWellPath.h
${CMAKE_CURRENT_LIST_DIR}/RimWellPathGeometryDef.h
${CMAKE_CURRENT_LIST_DIR}/RimWellPathCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimWellPathTarget.h
${CMAKE_CURRENT_LIST_DIR}/RimScriptCollection.h
@ -138,6 +139,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimSimWellInViewCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellPath.cpp
${CMAKE_CURRENT_LIST_DIR}/RimFileWellPath.cpp
${CMAKE_CURRENT_LIST_DIR}/RimModeledWellPath.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellPathGeometryDef.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellPathCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellPathTarget.cpp
${CMAKE_CURRENT_LIST_DIR}/RimScriptCollection.cpp

View File

@ -1,14 +1,30 @@
#include "RimModeledWellPath.h"
#include "cafPdmUiTableViewEditor.h"
#include "RimWellPathTarget.h"
#include "cafPdmUiTreeOrdering.h"
#include "cafCmdFeatureMenuBuilder.h"
#include "RigWellPath.h"
#include "RimProject.h"
#include "cvfGeometryTools.h"
#include "cvfMatrix4.h"
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018 - equinor 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 "RimModeledWellPath.h"
#include "RimWellPathGeometryDef.h"
#include "RimProject.h"
#include "RigWellPath.h"
#include "cafPdmUiTreeOrdering.h"
#include "RiaPolyArcLineSampler.h"
CAF_PDM_SOURCE_INIT(RimModeledWellPath, "ModeledWellPath");
@ -61,190 +77,3 @@ void RimModeledWellPath::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrde
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", "", "", "");
CAF_PDM_InitField(&m_referencePoint, "ReferencePos", cvf::Vec3d(0,0,0), "UTM Reference Point", "", "", "");
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()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathGeometryDef::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue)
{
if (&m_referencePoint == changedField)
{
std::cout << "fieldChanged" << std::endl;
}
updateWellPathVisualization();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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)
{
m_kickoffDepthOrMD.uiCapability()->setUiName("Kick-Off Depth");
uiOrdering.add(&m_kickoffDepthOrMD);
}
uiOrdering.add(&m_referencePoint);
uiOrdering.add(&m_wellTargets);
uiOrdering.skipRemainingFields(true);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathGeometryDef::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName)
{
uiTreeOrdering.skipRemainingChildren(true);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathGeometryDef::defineCustomContextMenu(const caf::PdmFieldHandle* fieldNeedingMenu,
QMenu* menu,
QWidget* fieldEditorWidget)
{
caf::CmdFeatureMenuBuilder menuBuilder;
menuBuilder << "RicNewWellPathListTargetFeature";
menuBuilder << "Separator";
menuBuilder << "RicDeleteWellPathTargetFeature";
menuBuilder.appendToMenu(menu);
}

View File

@ -49,43 +49,3 @@ private:
};
class RimWellPathGeometryDef : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimWellPathGeometryDef();
~RimWellPathGeometryDef();
enum WellStartType { START_AT_FIRST_TARGET, START_AT_SURFACE, START_FROM_OTHER_WELL, START_AT_AUTO_SURFACE };
cvf::ref<RigWellPath> createWellPathGeometry();
void updateWellPathVisualization();
void insertTarget(RimWellPathTarget* targetToInsertBefore, RimWellPathTarget* targetToInsert);
void deleteTarget(RimWellPathTarget* targetTodelete);
private:
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName) override;
std::vector<cvf::Vec3d> lineArcEndpoints();
caf::PdmField<caf::AppEnum<WellStartType> > m_wellStartType;
caf::PdmField<cvf::Vec3d> m_referencePoint;
caf::PdmField<double> m_kickoffDepthOrMD;
caf::PdmPtrField<RimWellPath*> m_parentWell;
caf::PdmChildArrayField<RimWellPathTarget*> m_wellTargets;
protected:
virtual void defineCustomContextMenu(const caf::PdmFieldHandle* fieldNeedingMenu,
QMenu* menu,
QWidget* fieldEditorWidget) override;
};

View File

@ -0,0 +1,200 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018 - equinor 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 "RimWellPathGeometryDef.h"
#include "cafCmdFeatureMenuBuilder.h"
#include "cafPdmUiTableViewEditor.h"
#include "cafPdmUiTreeOrdering.h"
#include "RigWellPath.h"
#include "RiaPolyArcLineSampler.h"
#include "RimWellPathTarget.h"
#include "RimModeledWellPath.h"
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", "", "", "");
CAF_PDM_InitField(&m_referencePoint, "ReferencePos", cvf::Vec3d(0,0,0), "UTM Reference Point", "", "", "");
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()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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));
return wellPathGeometry;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathGeometryDef::updateWellPathVisualization()
{
RimModeledWellPath* modWellPath;
this->firstAncestorOrThisOfTypeAsserted(modWellPath);
modWellPath->updateWellPathVisualization();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathGeometryDef::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue)
{
if (&m_referencePoint == changedField)
{
std::cout << "fieldChanged" << std::endl;
}
updateWellPathVisualization();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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)
{
m_kickoffDepthOrMD.uiCapability()->setUiName("Kick-Off Depth");
uiOrdering.add(&m_kickoffDepthOrMD);
}
uiOrdering.add(&m_referencePoint);
uiOrdering.add(&m_wellTargets);
uiOrdering.skipRemainingFields(true);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathGeometryDef::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName)
{
uiTreeOrdering.skipRemainingChildren(true);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathGeometryDef::defineCustomContextMenu(const caf::PdmFieldHandle* fieldNeedingMenu,
QMenu* menu,
QWidget* fieldEditorWidget)
{
caf::CmdFeatureMenuBuilder menuBuilder;
menuBuilder << "RicNewWellPathListTargetFeature";
menuBuilder << "Separator";
menuBuilder << "RicDeleteWellPathTargetFeature";
menuBuilder.appendToMenu(menu);
}

View File

@ -0,0 +1,74 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018 - equinor 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 "cvfBase.h"
#include "cvfObject.h"
#include "cafPdmObject.h"
#include "cafAppEnum.h"
#include "cafPdmField.h"
#include "cafPdmFieldCvfVec3d.h"
#include "cafPdmPtrField.h"
#include "cafPdmChildArrayField.h"
class RimWellPath;
class RimWellPathTarget;
class RigWellPath;
class RimWellPathGeometryDef : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimWellPathGeometryDef();
~RimWellPathGeometryDef() override;
enum WellStartType { START_AT_FIRST_TARGET, START_AT_SURFACE, START_FROM_OTHER_WELL, START_AT_AUTO_SURFACE };
cvf::ref<RigWellPath> createWellPathGeometry();
void updateWellPathVisualization();
void insertTarget(RimWellPathTarget* targetToInsertBefore, RimWellPathTarget* targetToInsert);
void deleteTarget(RimWellPathTarget* targetTodelete);
private:
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName) override;
std::vector<cvf::Vec3d> lineArcEndpoints();
caf::PdmField<caf::AppEnum<WellStartType> > m_wellStartType;
caf::PdmField<cvf::Vec3d> m_referencePoint;
caf::PdmField<double> m_kickoffDepthOrMD;
caf::PdmPtrField<RimWellPath*> m_parentWell;
caf::PdmChildArrayField<RimWellPathTarget*> m_wellTargets;
protected:
virtual void defineCustomContextMenu(const caf::PdmFieldHandle* fieldNeedingMenu,
QMenu* menu,
QWidget* fieldEditorWidget) override;
};