#3447, #3207, #3448 Polished the target table. Improved insert target commands, Add icons to editable wellpaths and target list.

This commit is contained in:
Jacob Støren 2018-10-02 15:55:28 +02:00
parent 1dfad4f01d
commit d9e8537974
9 changed files with 116 additions and 15 deletions

View File

@ -57,18 +57,50 @@ bool RicNewWellPathListTargetFeature::isCommandEnabled()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicNewWellPathListTargetFeature::onActionTriggered(bool isChecked) void RicNewWellPathListTargetFeature::onActionTriggered(bool isChecked)
{ {
std::vector<RimWellPathTarget*> targets; std::vector<RimWellPathTarget*> selectedTargets;
caf::SelectionManager::instance()->objectsByType(&targets, caf::SelectionManager::FIRST_LEVEL); caf::SelectionManager::instance()->objectsByType(&selectedTargets, caf::SelectionManager::FIRST_LEVEL);
if (targets.size() > 0) if (selectedTargets.size() > 0)
{ {
auto firstTarget = targets.front(); auto firstTarget = selectedTargets.front();
RimWellPathGeometryDef* wellGeomDef = nullptr; RimWellPathGeometryDef* wellGeomDef = nullptr;
firstTarget->firstAncestorOrThisOfTypeAsserted(wellGeomDef); firstTarget->firstAncestorOrThisOfTypeAsserted(wellGeomDef);
RimWellPathTarget* duplicate = dynamic_cast<RimWellPathTarget*>(firstTarget->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); auto afterBeforePair = wellGeomDef->findActiveTargetsAroundInsertionPoint(firstTarget);
wellGeomDef->insertTarget(firstTarget, duplicate);
cvf::Vec3d newPos = cvf::Vec3d::ZERO;
if (!afterBeforePair.first && afterBeforePair.second)
{
newPos = afterBeforePair.second->targetPointXYZ();
newPos.z() = -wellGeomDef->referencePointXyz().z();
}
else if (afterBeforePair.first && afterBeforePair.second)
{
newPos = 0.5*(afterBeforePair.first->targetPointXYZ() + afterBeforePair.second->targetPointXYZ());
}
else if (afterBeforePair.first && !afterBeforePair.second)
{
std::vector<RimWellPathTarget*> activeTargets = wellGeomDef->activeWellTargets();
size_t targetCount = activeTargets.size();
if (targetCount > 1)
{
newPos = activeTargets[targetCount-1]->targetPointXYZ();
cvf::Vec3d nextLastToLast = newPos - activeTargets[targetCount-2]->targetPointXYZ();
newPos += 0.5*nextLastToLast;
}
else
{
newPos = afterBeforePair.first->targetPointXYZ() + cvf::Vec3d(0, 0, 200);
}
}
RimWellPathTarget* newTarget = new RimWellPathTarget;
newTarget->setAsPointTargetXYD({ newPos[0], newPos[1], -newPos[2] });
wellGeomDef->insertTarget(firstTarget, newTarget);
wellGeomDef->updateConnectedEditors(); wellGeomDef->updateConnectedEditors();
wellGeomDef->updateWellPathVisualization(); wellGeomDef->updateWellPathVisualization();
return; return;
} }
@ -77,8 +109,34 @@ void RicNewWellPathListTargetFeature::onActionTriggered(bool isChecked)
if (geomDefs.size() > 0) if (geomDefs.size() > 0)
{ {
RimWellPathGeometryDef* wellGeomDef = geomDefs[0]; RimWellPathGeometryDef* wellGeomDef = geomDefs[0];
std::vector<RimWellPathTarget*> activeTargets = wellGeomDef->activeWellTargets();
size_t targetCount = activeTargets.size();
if ( targetCount == 0 )
{
wellGeomDef->appendTarget();
}
else
{
cvf::Vec3d newPos = cvf::Vec3d::ZERO;
if ( targetCount > 1 )
{
newPos = activeTargets[targetCount-1]->targetPointXYZ();
cvf::Vec3d nextLastToLast = newPos - activeTargets[targetCount-2]->targetPointXYZ();
newPos += 0.5*nextLastToLast;
}
else if ( targetCount > 0 )
{
newPos = activeTargets[targetCount-1]->targetPointXYZ() + cvf::Vec3d(0, 0, 200);
}
RimWellPathTarget* newTarget = new RimWellPathTarget;
newTarget->setAsPointTargetXYD({ newPos[0], newPos[1], -newPos[2] });
wellGeomDef->insertTarget(nullptr, newTarget);
}
wellGeomDef->appendTarget();
wellGeomDef->updateConnectedEditors(); wellGeomDef->updateConnectedEditors();
wellGeomDef->updateWellPathVisualization(); wellGeomDef->updateWellPathVisualization();
} }

View File

@ -40,7 +40,7 @@ CAF_PDM_SOURCE_INIT(RimModeledWellPath, "ModeledWellPath");
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimModeledWellPath::RimModeledWellPath() RimModeledWellPath::RimModeledWellPath()
{ {
CAF_PDM_InitObject("Modeled WellPath", ":/Well.png", "", ""); CAF_PDM_InitObject("Modeled WellPath", ":/EditableWell.png", "", "");
CAF_PDM_InitFieldNoDefault(&m_geometryDefinition, "WellPathGeometryDef", "Trajectory", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_geometryDefinition, "WellPathGeometryDef", "Trajectory", "", "", "");
m_geometryDefinition = new RimWellPathGeometryDef; m_geometryDefinition = new RimWellPathGeometryDef;

View File

@ -58,7 +58,7 @@ CAF_PDM_SOURCE_INIT(RimWellPathGeometryDef, "WellPathGeometryDef");
RimWellPathGeometryDef::RimWellPathGeometryDef() RimWellPathGeometryDef::RimWellPathGeometryDef()
: m_pickTargetsEventHandler(new RicCreateWellTargetsPickEventHandler(this)) : m_pickTargetsEventHandler(new RicCreateWellTargetsPickEventHandler(this))
{ {
CAF_PDM_InitObject("Well Targets", ":/Well.png", "", ""); CAF_PDM_InitObject("Well Targets", ":/WellTargets.png", "", "");
CAF_PDM_InitField(&m_referencePointUtmXyd, "ReferencePosUtmXyd", cvf::Vec3d(0,0,0), "UTM Reference Point", "", "", ""); CAF_PDM_InitField(&m_referencePointUtmXyd, "ReferencePosUtmXyd", cvf::Vec3d(0,0,0), "UTM Reference Point", "", "", "");
@ -164,6 +164,31 @@ void RimWellPathGeometryDef::updateWellPathVisualization()
modWellPath->updateWellPathVisualization(); modWellPath->updateWellPathVisualization();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<RimWellPathTarget*, RimWellPathTarget*>
RimWellPathGeometryDef::findActiveTargetsAroundInsertionPoint(const RimWellPathTarget* targetToInsertBefore)
{
RimWellPathTarget* before = nullptr;
RimWellPathTarget* after = nullptr;
bool foundTarget = false;
for (const auto& wt : m_wellTargets)
{
if ( wt == targetToInsertBefore )
{
foundTarget = true;
}
if ( wt->isEnabled() && !after && foundTarget ) after = wt;
if ( wt->isEnabled() && !foundTarget ) before = wt;
}
return { before, after};
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -51,6 +51,7 @@ public:
cvf::ref<RigWellPath> createWellPathGeometry(); cvf::ref<RigWellPath> createWellPathGeometry();
void updateWellPathVisualization(); void updateWellPathVisualization();
std::pair<RimWellPathTarget*, RimWellPathTarget*> findActiveTargetsAroundInsertionPoint(const RimWellPathTarget* targetToInsertBefore);
void insertTarget(const RimWellPathTarget* targetToInsertBefore, void insertTarget(const RimWellPathTarget* targetToInsertBefore,
RimWellPathTarget* targetToInsert); RimWellPathTarget* targetToInsert);

View File

@ -3,6 +3,7 @@
#include <cmath> #include <cmath>
#include "RimWellPathGeometryDef.h" #include "RimWellPathGeometryDef.h"
#include "cafPdmUiCheckBoxEditor.h"
CAF_PDM_SOURCE_INIT(RimWellPathTarget, "WellPathTarget"); CAF_PDM_SOURCE_INIT(RimWellPathTarget, "WellPathTarget");
@ -28,13 +29,16 @@ RimWellPathTarget::RimWellPathTarget()
{ {
CAF_PDM_InitField(&m_isEnabled, "IsEnabled", true, "", "", "", ""); CAF_PDM_InitField(&m_isEnabled, "IsEnabled", true, "", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_targetType, "TargetType", "Type", "", "", "");
//m_targetType.uiCapability()->setUiHidden(true); //m_targetType.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&m_dogleg1, "Dogleg1", 3.0, "DLS 1", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_targetPoint, "TargetPoint", "Point", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_targetPoint, "TargetPoint", "Point", "", "", "");
CAF_PDM_InitField(&m_dogleg1, "Dogleg1", 3.0, "DLh", "", "", "");
CAF_PDM_InitField(&m_dogleg2, "Dogleg2", 3.0, "DLl", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_targetType, "TargetType", "Type", "", "", "");
m_targetType.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&m_hasTangentConstraintUiField, "HasTangentConstraint", false, "Dir", "", "", "");
m_hasTangentConstraintUiField.xmlCapability()->disableIO();
CAF_PDM_InitField(&m_azimuth, "Azimuth", 0.0, "Azi(deg)", "", "", ""); CAF_PDM_InitField(&m_azimuth, "Azimuth", 0.0, "Azi(deg)", "", "", "");
CAF_PDM_InitField(&m_inclination, "Inclination", 0.0, "Inc(deg)", "", "", ""); CAF_PDM_InitField(&m_inclination, "Inclination", 0.0, "Inc(deg)", "", "", "");
CAF_PDM_InitField(&m_dogleg2, "Dogleg2", 3.0, "DLS 2", "", "", "");
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -252,8 +256,8 @@ QList<caf::PdmOptionItemInfo> RimWellPathTarget::calculateValueOptions(const caf
QList<caf::PdmOptionItemInfo> options; QList<caf::PdmOptionItemInfo> options;
if (fieldNeedingOptions == & m_targetType) if (fieldNeedingOptions == & m_targetType)
{ {
options.push_back(caf::PdmOptionItemInfo("o->",RimWellPathTarget::POINT_AND_TANGENT, false, QIcon(":/WellTargetPointTangent16x16.png") )); options.push_back(caf::PdmOptionItemInfo("o->",RimWellPathTarget::POINT_AND_TANGENT));//, false, QIcon(":/WellTargetPointTangent16x16.png") ));
options.push_back(caf::PdmOptionItemInfo("o", RimWellPathTarget::POINT, false, QIcon(":/WellTargetPoint16x16.png"))); options.push_back(caf::PdmOptionItemInfo("o", RimWellPathTarget::POINT));//, false, QIcon(":/WellTargetPoint16x16.png")));
} }
return options; return options;
} }
@ -263,6 +267,12 @@ QList<caf::PdmOptionItemInfo> RimWellPathTarget::calculateValueOptions(const caf
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellPathTarget::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) void RimWellPathTarget::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{ {
if (changedField == &m_hasTangentConstraintUiField)
{
if (m_hasTangentConstraintUiField) m_targetType = POINT_AND_TANGENT;
else m_targetType = POINT;
}
RimModeledWellPath* wellPath; RimModeledWellPath* wellPath;
firstAncestorOrThisOfTypeAsserted(wellPath); firstAncestorOrThisOfTypeAsserted(wellPath);
wellPath->updateWellPathVisualization(); wellPath->updateWellPathVisualization();
@ -270,6 +280,7 @@ void RimWellPathTarget::fieldChangedByUi(const caf::PdmFieldHandle* changedField
{ {
wellPath->scheduleUpdateOfDependentVisualization(); wellPath->scheduleUpdateOfDependentVisualization();
} }
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -277,9 +288,11 @@ void RimWellPathTarget::fieldChangedByUi(const caf::PdmFieldHandle* changedField
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimWellPathTarget::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) void RimWellPathTarget::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{ {
m_hasTangentConstraintUiField = (m_targetType == POINT_AND_TANGENT);
if (m_isEnabled()) if (m_isEnabled())
{ {
m_hasTangentConstraintUiField.uiCapability()->setUiReadOnly(false);
m_targetType.uiCapability()->setUiReadOnly(false); m_targetType.uiCapability()->setUiReadOnly(false);
m_targetPoint.uiCapability()->setUiReadOnly(false); m_targetPoint.uiCapability()->setUiReadOnly(false);
m_dogleg2.uiCapability()->setUiReadOnly(false); m_dogleg2.uiCapability()->setUiReadOnly(false);
@ -318,5 +331,6 @@ void RimWellPathTarget::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderin
m_azimuth.uiCapability()->setUiReadOnly(true); m_azimuth.uiCapability()->setUiReadOnly(true);
m_inclination.uiCapability()->setUiReadOnly(true); m_inclination.uiCapability()->setUiReadOnly(true);
m_dogleg2.uiCapability()->setUiReadOnly(true); m_dogleg2.uiCapability()->setUiReadOnly(true);
m_hasTangentConstraintUiField.uiCapability()->setUiReadOnly(true);
} }
} }

View File

@ -68,6 +68,7 @@ private:
caf::PdmField<double> m_inclination; caf::PdmField<double> m_inclination;
caf::PdmField<double> m_dogleg1; caf::PdmField<double> m_dogleg1;
caf::PdmField<double> m_dogleg2; caf::PdmField<double> m_dogleg2;
caf::PdmField<bool> m_hasTangentConstraintUiField;
}; };

Binary file not shown.

After

Width:  |  Height:  |  Size: 466 B

View File

@ -18,6 +18,8 @@
<file>Minus.png</file> <file>Minus.png</file>
<file>Save.png</file> <file>Save.png</file>
<file>Well.png</file> <file>Well.png</file>
<file>EditableWell.png</file>
<file>WellTargets.png</file>
<file>WellCollection.png</file> <file>WellCollection.png</file>
<file>octave.png</file> <file>octave.png</file>
<file>OctaveScriptFile16x16.png</file> <file>OctaveScriptFile16x16.png</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 B