mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-14 09:22:13 -05:00
Simplify pick event system
This commit is contained in:
1 parent
fac9870c76
commit
d9672ad9a1
28 files changed
+315
-390
No files matched your search
@@ -47,7 +47,6 @@ RicMeasurementPickEventHandler* RicMeasurementPickEventHandler::instance()
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicMeasurementPickEventHandler::RicMeasurementPickEventHandler()
|
||||
: Ric3dViewPickEventHandler(nullptr)
|
||||
{}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -20,13 +20,6 @@
|
||||
|
||||
#include <typeinfo>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
Ric3dViewPickEventHandler::Ric3dViewPickEventHandler(const caf::PdmObjectHandle* handlingObject)
|
||||
: caf::PickEventHandler(handlingObject)
|
||||
{}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -28,8 +28,6 @@
|
||||
class Ric3dViewPickEventHandler : public caf::PickEventHandler
|
||||
{
|
||||
public:
|
||||
Ric3dViewPickEventHandler(const caf::PdmObjectHandle* handlingObject);
|
||||
|
||||
// Override from caf
|
||||
void registerAsPickEventHandler() override;
|
||||
void unregisterAsPickEventHandler() override;
|
||||
|
||||
@@ -26,10 +26,8 @@
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicVec3dPickEventHandler::RicVec3dPickEventHandler(const caf::PdmObjectHandle* handlingObject,
|
||||
caf::PdmField<cvf::Vec3d>* vectorField)
|
||||
: Ric3dViewPickEventHandler(handlingObject)
|
||||
, m_vectorField(vectorField)
|
||||
RicVec3dPickEventHandler::RicVec3dPickEventHandler(caf::PdmField<cvf::Vec3d>* vectorField)
|
||||
: m_vectorField(vectorField)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -38,19 +36,14 @@ RicVec3dPickEventHandler::RicVec3dPickEventHandler(const caf::PdmObjectHandle* h
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicVec3dPickEventHandler::handle3dPickEvent(const Ric3dPickEvent& eventObject)
|
||||
{
|
||||
caf::PdmObjectHandle* selectedObject = caf::SelectionManager::instance()->selectedItemOfType<caf::PdmObjectHandle>();
|
||||
if (isObjectBeingModified(selectedObject))
|
||||
{
|
||||
const Rim3dView* rimView = eventObject.m_view;
|
||||
const Rim3dView* rimView = eventObject.m_view;
|
||||
|
||||
cvf::ref<caf::DisplayCoordTransform> transForm = rimView->displayCoordTransform();
|
||||
cvf::Vec3d pickedPositionInUTM = transForm->transformToDomainCoord(eventObject.m_pickItemInfos.front().globalPickedPoint());
|
||||
cvf::ref<caf::DisplayCoordTransform> transForm = rimView->displayCoordTransform();
|
||||
cvf::Vec3d pickedPositionInUTM = transForm->transformToDomainCoord(eventObject.m_pickItemInfos.front().globalPickedPoint());
|
||||
|
||||
pickedPositionInUTM.z() *= -1.0;
|
||||
m_vectorField->setValueWithFieldChanged(pickedPositionInUTM);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
pickedPositionInUTM.z() *= -1.0;
|
||||
m_vectorField->setValueWithFieldChanged(pickedPositionInUTM);
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -29,7 +29,7 @@ class Rim3dView;
|
||||
class RicVec3dPickEventHandler : public Ric3dViewPickEventHandler
|
||||
{
|
||||
public:
|
||||
RicVec3dPickEventHandler(const caf::PdmObjectHandle* handlingObject, caf::PdmField<cvf::Vec3d>* vectorField);
|
||||
RicVec3dPickEventHandler(caf::PdmField<cvf::Vec3d>* vectorField);
|
||||
bool handle3dPickEvent(const Ric3dPickEvent& eventObject) override;
|
||||
|
||||
|
||||
|
||||
+17
@@ -23,6 +23,7 @@
|
||||
#include "RimPolylineTarget.h"
|
||||
#include "RimUserDefinedPolylinesAnnotation.h"
|
||||
|
||||
#include "cafPickEventHandler.h"
|
||||
|
||||
CAF_PDM_UI_3D_OBJECT_EDITOR_SOURCE_INIT(RicPolyline3dEditor);
|
||||
|
||||
@@ -43,6 +44,10 @@ RicPolyline3dEditor::~RicPolyline3dEditor()
|
||||
{
|
||||
delete targetEditor;
|
||||
}
|
||||
if (m_attribute.pickEventHandler != nullptr)
|
||||
{
|
||||
m_attribute.pickEventHandler->unregisterAsPickEventHandler();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -60,6 +65,18 @@ void RicPolyline3dEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
|
||||
if (!geomDef) return;
|
||||
|
||||
geomDef->objectEditorAttribute("", &m_attribute);
|
||||
if (m_attribute.pickEventHandler != nullptr)
|
||||
{
|
||||
if (m_attribute.enablePicking)
|
||||
{
|
||||
m_attribute.pickEventHandler->registerAsPickEventHandler();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_attribute.pickEventHandler->unregisterAsPickEventHandler();
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<RimPolylineTarget*> targets = geomDef->activeTargets();
|
||||
|
||||
|
||||
+31
-2
@@ -17,10 +17,39 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmUi3dObjectEditorHandle.h"
|
||||
#include "cafPdmUiFieldEditorHandle.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace caf
|
||||
{
|
||||
class PickEventHandler;
|
||||
};
|
||||
|
||||
class RicPolylineTarget3dEditor;
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicPolyline3dEditorAttribute : public caf::PdmUiEditorAttribute
|
||||
{
|
||||
public:
|
||||
RicPolyline3dEditorAttribute()
|
||||
: enablePicking(false)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
bool enablePicking;
|
||||
std::shared_ptr<caf::PickEventHandler> pickEventHandler;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicPolyline3dEditor : public caf::PdmUi3dObjectEditorHandle
|
||||
{
|
||||
CAF_PDM_UI_3D_OBJECT_EDITOR_HEADER_INIT;
|
||||
@@ -32,9 +61,9 @@ public:
|
||||
protected:
|
||||
void configureAndUpdateUi(const QString& uiConfigName) override;
|
||||
|
||||
private:
|
||||
|
||||
private:
|
||||
std::vector<RicPolylineTarget3dEditor*> m_targetEditors;
|
||||
RicPolyline3dEditorAttribute m_attribute;
|
||||
};
|
||||
|
||||
|
||||
+18
@@ -24,6 +24,7 @@
|
||||
#include "RimWellPathTarget.h"
|
||||
#include "RimWellPathGeometryDef.h"
|
||||
|
||||
#include "cafPickEventHandler.h"
|
||||
|
||||
CAF_PDM_UI_3D_OBJECT_EDITOR_SOURCE_INIT(RicWellPathGeometry3dEditor);
|
||||
|
||||
@@ -44,6 +45,10 @@ RicWellPathGeometry3dEditor::~RicWellPathGeometry3dEditor()
|
||||
{
|
||||
delete targetEditor;
|
||||
}
|
||||
if (m_attribute.pickEventHandler)
|
||||
{
|
||||
m_attribute.pickEventHandler->unregisterAsPickEventHandler();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -61,6 +66,7 @@ void RicWellPathGeometry3dEditor::configureAndUpdateUi(const QString& uiConfigNa
|
||||
|
||||
if (!geomDef) return;
|
||||
|
||||
geomDef->objectEditorAttribute("", &m_attribute);
|
||||
|
||||
std::vector<RimWellPathTarget*> targets = geomDef->activeWellTargets();
|
||||
|
||||
@@ -72,6 +78,18 @@ void RicWellPathGeometry3dEditor::configureAndUpdateUi(const QString& uiConfigNa
|
||||
m_targetEditors.push_back(targetEditor);
|
||||
targetEditor->updateUi();
|
||||
}
|
||||
|
||||
if (m_attribute.pickEventHandler)
|
||||
{
|
||||
if (m_attribute.enablePicking)
|
||||
{
|
||||
m_attribute.pickEventHandler->registerAsPickEventHandler();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_attribute.pickEventHandler->unregisterAsPickEventHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+18
-2
@@ -18,9 +18,25 @@
|
||||
|
||||
#pragma once
|
||||
#include "cafPdmUi3dObjectEditorHandle.h"
|
||||
#include "cafPdmUiFieldEditorHandle.h"
|
||||
#include <memory>
|
||||
|
||||
namespace caf
|
||||
{
|
||||
class PickEventHandler;
|
||||
}
|
||||
|
||||
class RicWellTarget3dEditor;
|
||||
|
||||
|
||||
class RicWellPathGeometry3dEditorAttribute : public caf::PdmUiEditorAttribute
|
||||
{
|
||||
public:
|
||||
RicWellPathGeometry3dEditorAttribute() : enablePicking(false) {}
|
||||
bool enablePicking;
|
||||
std::shared_ptr<caf::PickEventHandler> pickEventHandler;
|
||||
};
|
||||
|
||||
class RicWellPathGeometry3dEditor : public caf::PdmUi3dObjectEditorHandle
|
||||
{
|
||||
CAF_PDM_UI_3D_OBJECT_EDITOR_HEADER_INIT;
|
||||
@@ -33,8 +49,8 @@ protected:
|
||||
void configureAndUpdateUi(const QString& uiConfigName) override;
|
||||
|
||||
private:
|
||||
|
||||
std::vector<RicWellTarget3dEditor*> m_targetEditors;
|
||||
std::vector<RicWellTarget3dEditor*> m_targetEditors;
|
||||
RicWellPathGeometry3dEditorAttribute m_attribute;
|
||||
};
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "RicCreateWellTargetsPickEventHandler.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaOffshoreSphericalCoords.h"
|
||||
|
||||
#include "RigFemPart.h"
|
||||
@@ -55,7 +56,7 @@
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicCreateWellTargetsPickEventHandler::RicCreateWellTargetsPickEventHandler(RimWellPathGeometryDef* wellGeometryDef)
|
||||
: Ric3dViewPickEventHandler(wellGeometryDef), m_geometryToAddTargetsTo(wellGeometryDef)
|
||||
: m_geometryToAddTargetsTo(wellGeometryDef)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -64,12 +65,21 @@ RicCreateWellTargetsPickEventHandler::RicCreateWellTargetsPickEventHandler(RimWe
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicCreateWellTargetsPickEventHandler::~RicCreateWellTargetsPickEventHandler() {}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCreateWellTargetsPickEventHandler::registerAsPickEventHandler()
|
||||
{
|
||||
RiaApplication::instance()->setOverrideCursor(Qt::CrossCursor);
|
||||
Ric3dViewPickEventHandler::registerAsPickEventHandler();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCreateWellTargetsPickEventHandler::notifyUnregistered()
|
||||
{
|
||||
m_geometryToAddTargetsTo->enableTargetPointPicking(false);
|
||||
RiaApplication::instance()->restoreOverrideCursor();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -77,13 +87,6 @@ void RicCreateWellTargetsPickEventHandler::notifyUnregistered()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicCreateWellTargetsPickEventHandler::handle3dPickEvent(const Ric3dPickEvent& eventObject)
|
||||
{
|
||||
if (!isObjectBeingModified(caf::SelectionManager::instance()->selectedItemOfType<caf::PdmObjectHandle>()))
|
||||
{
|
||||
m_geometryToAddTargetsTo->enableTargetPointPicking(false);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_geometryToAddTargetsTo)
|
||||
{
|
||||
Rim3dView* rimView = eventObject.m_view;
|
||||
|
||||
@@ -34,6 +34,8 @@ public:
|
||||
RicCreateWellTargetsPickEventHandler(RimWellPathGeometryDef* wellGeometryDef);
|
||||
~RicCreateWellTargetsPickEventHandler();
|
||||
|
||||
void registerAsPickEventHandler() override;
|
||||
|
||||
protected:
|
||||
bool handle3dPickEvent(const Ric3dPickEvent& eventObject) override;
|
||||
void notifyUnregistered() override;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "RicPolylineTargetsPickEventHandler.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaOffshoreSphericalCoords.h"
|
||||
|
||||
#include "RigWellPath.h"
|
||||
@@ -40,7 +41,7 @@
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicPolylineTargetsPickEventHandler::RicPolylineTargetsPickEventHandler(RimUserDefinedPolylinesAnnotation* polylineDef)
|
||||
: Ric3dViewPickEventHandler(polylineDef), m_polylineDef(polylineDef)
|
||||
: m_polylineDef(polylineDef)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -49,12 +50,21 @@ RicPolylineTargetsPickEventHandler::RicPolylineTargetsPickEventHandler(RimUserDe
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicPolylineTargetsPickEventHandler::~RicPolylineTargetsPickEventHandler() {}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPolylineTargetsPickEventHandler::registerAsPickEventHandler()
|
||||
{
|
||||
RiaApplication::instance()->setOverrideCursor(Qt::CrossCursor);
|
||||
Ric3dViewPickEventHandler::registerAsPickEventHandler();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPolylineTargetsPickEventHandler::notifyUnregistered()
|
||||
{
|
||||
//m_polylineDef->enableTargetPointPicking(false);
|
||||
RiaApplication::instance()->restoreOverrideCursor();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -62,11 +72,6 @@ void RicPolylineTargetsPickEventHandler::notifyUnregistered()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicPolylineTargetsPickEventHandler::handle3dPickEvent(const Ric3dPickEvent& eventObject)
|
||||
{
|
||||
if (!isObjectBeingModified(caf::SelectionManager::instance()->selectedItemOfType<caf::PdmObjectHandle>()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_polylineDef)
|
||||
{
|
||||
Rim3dView* rimView = eventObject.m_view;
|
||||
|
||||
@@ -33,6 +33,8 @@ public:
|
||||
RicPolylineTargetsPickEventHandler(RimUserDefinedPolylinesAnnotation* polylineDef);
|
||||
~RicPolylineTargetsPickEventHandler();
|
||||
|
||||
void registerAsPickEventHandler() override;
|
||||
|
||||
protected:
|
||||
bool handle3dPickEvent(const Ric3dPickEvent& eventObject) override;
|
||||
void notifyUnregistered() override;
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
|
||||
#include "RicVec3dPickEventHandler.h"
|
||||
|
||||
#include "cafPdmUiVec3dEditor.h"
|
||||
#include "cafPdmUiPushButtonEditor.h"
|
||||
#include "cafPdmUiPickableLineEditor.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimReachCircleAnnotation, "RimReachCircleAnnotation");
|
||||
|
||||
@@ -42,7 +43,11 @@ RimReachCircleAnnotation::RimReachCircleAnnotation()
|
||||
m_isActive.uiCapability()->setUiHidden(true);
|
||||
|
||||
CAF_PDM_InitField(&m_centerPointXyd, "CenterPointXyd", Vec3d::ZERO, "Center Point", "", "", "");
|
||||
m_centerPointXyd.uiCapability()->setUiEditorTypeName(caf::PdmUiVec3dEditor::uiEditorTypeName());
|
||||
m_centerPointXyd.uiCapability()->setUiEditorTypeName(caf::PdmUiPickableLineEditor::uiEditorTypeName());
|
||||
CAF_PDM_InitField(&m_centerPointPickEnabled, "AnchorPointPick", true, "", "", "", "");
|
||||
caf::PdmUiPushButtonEditor::configureEditorForField(&m_centerPointPickEnabled);
|
||||
m_centerPointPickEnabled.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::LabelPosType::HIDDEN);
|
||||
|
||||
CAF_PDM_InitField(&m_radius, "Radius", 100.0, "Radius", "", "", "");
|
||||
CAF_PDM_InitField(&m_name, "Name", QString("Circle Annotation"), "Name", "", "", "");
|
||||
|
||||
@@ -52,7 +57,7 @@ RimReachCircleAnnotation::RimReachCircleAnnotation()
|
||||
m_appearance.uiCapability()->setUiTreeHidden(true);
|
||||
m_appearance.uiCapability()->setUiTreeChildrenHidden(true);
|
||||
|
||||
m_centerPointEventHandler.reset(new RicVec3dPickEventHandler(this, &m_centerPointXyd));
|
||||
m_centerPointEventHandler.reset(new RicVec3dPickEventHandler(&m_centerPointXyd));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -115,6 +120,7 @@ void RimReachCircleAnnotation::defineUiOrdering(QString uiConfigName, caf::PdmUi
|
||||
{
|
||||
uiOrdering.add(&m_name);
|
||||
uiOrdering.add(&m_centerPointXyd);
|
||||
uiOrdering.add(&m_centerPointPickEnabled);
|
||||
uiOrdering.add(&m_radius);
|
||||
|
||||
auto appearanceGroup = uiOrdering.addNewGroup("Appearance");
|
||||
@@ -130,6 +136,15 @@ void RimReachCircleAnnotation::fieldChangedByUi(const caf::PdmFieldHandle* chang
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue)
|
||||
{
|
||||
if (changedField == &m_centerPointXyd)
|
||||
{
|
||||
m_centerPointPickEnabled = false;
|
||||
this->updateConnectedEditors();
|
||||
}
|
||||
if (changedField == &m_centerPointPickEnabled)
|
||||
{
|
||||
this->updateConnectedEditors();
|
||||
}
|
||||
RimAnnotationCollection* annColl = nullptr;
|
||||
this->firstAncestorOrThisOfTypeAsserted(annColl);
|
||||
|
||||
@@ -161,13 +176,30 @@ void RimReachCircleAnnotation::defineEditorAttribute(const caf::PdmFieldHandle*
|
||||
{
|
||||
if (field == &m_centerPointXyd)
|
||||
{
|
||||
caf::PdmUiVec3dEditorAttribute* attr = dynamic_cast<caf::PdmUiVec3dEditorAttribute*>(attribute);
|
||||
auto* attr = dynamic_cast<caf::PdmUiPickableLineEditorAttribute*>(attribute);
|
||||
if (attr)
|
||||
{
|
||||
attr->pickEventHandler = m_centerPointEventHandler;
|
||||
attr->enablePicking = m_centerPointPickEnabled;
|
||||
if (m_centerPointXyd().isZero())
|
||||
{
|
||||
attr->startInPickingMode = true;
|
||||
attr->enablePicking = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (field == &m_centerPointPickEnabled)
|
||||
{
|
||||
auto* attr = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>(attribute);
|
||||
if (attr)
|
||||
{
|
||||
if (m_centerPointPickEnabled)
|
||||
{
|
||||
attr->m_buttonText = "Stop";
|
||||
}
|
||||
else
|
||||
{
|
||||
attr->m_buttonText = "Pick";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@ private:
|
||||
caf::PdmField<bool> m_isActive;
|
||||
|
||||
caf::PdmField<Vec3d> m_centerPointXyd;
|
||||
caf::PdmField<bool> m_centerPointPickEnabled;
|
||||
caf::PdmField<double> m_radius;
|
||||
caf::PdmField<QString> m_name;
|
||||
caf::PdmChildField<RimReachCircleLineAppearance*> m_appearance;
|
||||
|
||||
@@ -29,9 +29,10 @@
|
||||
#include "AnnotationCommands/RicTextAnnotation3dEditor.h"
|
||||
|
||||
#include "cafCmdFeatureManager.h"
|
||||
#include "cafPdmUiPushButtonEditor.h"
|
||||
#include "cafPdmUiTextEditor.h"
|
||||
#include "cafPdmUiTreeOrdering.h"
|
||||
#include "cafPdmUiVec3dEditor.h"
|
||||
#include "cafPdmUiPickableLineEditor.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QPointer>
|
||||
@@ -48,9 +49,17 @@ RimTextAnnotation::RimTextAnnotation()
|
||||
this->setUi3dEditorTypeName(RicTextAnnotation3dEditor::uiEditorTypeName());
|
||||
|
||||
CAF_PDM_InitField(&m_anchorPointXyd, "AnchorPointXyd", Vec3d::ZERO, "Anchor Point", "", "", "");
|
||||
m_anchorPointXyd.uiCapability()->setUiEditorTypeName(caf::PdmUiVec3dEditor::uiEditorTypeName());
|
||||
m_anchorPointXyd.uiCapability()->setUiEditorTypeName(caf::PdmUiPickableLineEditor::uiEditorTypeName());
|
||||
CAF_PDM_InitField(&m_anchorPointPickEnabledButtonField, "AnchorPointPick", true, "", "", "", "");
|
||||
caf::PdmUiPushButtonEditor::configureEditorForField(&m_anchorPointPickEnabledButtonField);
|
||||
m_anchorPointPickEnabledButtonField.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::LabelPosType::HIDDEN);
|
||||
|
||||
CAF_PDM_InitField(&m_labelPointXyd, "LabelPointXyd", Vec3d::ZERO, "Label Point", "", "", "");
|
||||
m_labelPointXyd.uiCapability()->setUiEditorTypeName(caf::PdmUiVec3dEditor::uiEditorTypeName());
|
||||
m_labelPointXyd.uiCapability()->setUiEditorTypeName(caf::PdmUiPickableLineEditor::uiEditorTypeName());
|
||||
CAF_PDM_InitField(&m_labelPointPickEnabledButtonField, "LabelPointPick", false, "", "", "", "");
|
||||
caf::PdmUiPushButtonEditor::configureEditorForField(&m_labelPointPickEnabledButtonField);
|
||||
m_labelPointPickEnabledButtonField.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::LabelPosType::HIDDEN);
|
||||
|
||||
CAF_PDM_InitField(&m_text, "Text", QString("(New text)"), "Text", "", "", "");
|
||||
m_text.uiCapability()->setUiEditorTypeName(caf::PdmUiTextEditor::uiEditorTypeName());
|
||||
|
||||
@@ -67,8 +76,8 @@ RimTextAnnotation::RimTextAnnotation()
|
||||
m_nameProxy.uiCapability()->setUiReadOnly(true);
|
||||
m_nameProxy.xmlCapability()->disableIO();
|
||||
|
||||
m_anchorPointPickEventHandler.reset(new RicVec3dPickEventHandler(this, &m_anchorPointXyd));
|
||||
m_labelPointPickEventHandler.reset(new RicVec3dPickEventHandler(this, &m_labelPointXyd));
|
||||
m_anchorPointPickEventHandler.reset(new RicVec3dPickEventHandler(&m_anchorPointXyd));
|
||||
m_labelPointPickEventHandler.reset(new RicVec3dPickEventHandler(&m_labelPointXyd));
|
||||
|
||||
}
|
||||
|
||||
@@ -140,7 +149,10 @@ const QString& RimTextAnnotation::text() const
|
||||
void RimTextAnnotation::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
||||
{
|
||||
uiOrdering.add(&m_anchorPointXyd);
|
||||
uiOrdering.add(&m_anchorPointPickEnabledButtonField, false);
|
||||
uiOrdering.add(&m_labelPointXyd);
|
||||
uiOrdering.add(&m_labelPointPickEnabledButtonField, false);
|
||||
|
||||
uiOrdering.add(&m_text);
|
||||
|
||||
auto appearanceGroup = uiOrdering.addNewGroup("Text Appearance");
|
||||
@@ -156,15 +168,24 @@ void RimTextAnnotation::fieldChangedByUi(const caf::PdmFieldHandle* changedField
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue)
|
||||
{
|
||||
if (changedField == &m_anchorPointXyd && m_labelPointXyd().isZero())
|
||||
if (changedField == &m_anchorPointXyd)
|
||||
{
|
||||
m_labelPointXyd = m_anchorPointXyd();
|
||||
m_anchorPointPickEnabledButtonField = false;
|
||||
if (m_labelPointXyd().isZero())
|
||||
{
|
||||
m_labelPointXyd = m_anchorPointXyd;
|
||||
}
|
||||
this->updateConnectedEditors();
|
||||
}
|
||||
if (changedField == &m_labelPointXyd && m_anchorPointXyd().isZero())
|
||||
if (changedField == &m_labelPointXyd)
|
||||
{
|
||||
m_anchorPointXyd = m_labelPointXyd();
|
||||
m_labelPointPickEnabledButtonField = false;
|
||||
this->updateConnectedEditors();
|
||||
}
|
||||
if (changedField == &m_anchorPointPickEnabledButtonField || changedField == &m_labelPointPickEnabledButtonField)
|
||||
{
|
||||
this->updateConnectedEditors();
|
||||
}
|
||||
|
||||
|
||||
RimAnnotationCollectionBase* annColl = nullptr;
|
||||
this->firstAncestorOrThisOfTypeAsserted(annColl);
|
||||
@@ -226,20 +247,36 @@ void RimTextAnnotation::defineEditorAttribute(const caf::PdmFieldHandle* field,
|
||||
QString uiConfigName,
|
||||
caf::PdmUiEditorAttribute* attribute)
|
||||
{
|
||||
caf::PdmUiVec3dEditorAttribute* attr = dynamic_cast<caf::PdmUiVec3dEditorAttribute*>(attribute);
|
||||
caf::PdmUiPickableLineEditorAttribute* attr = dynamic_cast<caf::PdmUiPickableLineEditorAttribute*>(attribute);
|
||||
|
||||
if (attr && field == &m_anchorPointXyd)
|
||||
{
|
||||
attr->pickEventHandler = m_anchorPointPickEventHandler;
|
||||
if (m_anchorPointXyd().isZero())
|
||||
{
|
||||
attr->startInPickingMode = true;
|
||||
}
|
||||
attr->enablePicking = m_anchorPointPickEnabledButtonField;
|
||||
}
|
||||
else if (attr && field == &m_labelPointXyd)
|
||||
{
|
||||
attr->pickEventHandler = m_labelPointPickEventHandler;
|
||||
attr->enablePicking = m_labelPointPickEnabledButtonField;
|
||||
}
|
||||
|
||||
if (field == &m_anchorPointPickEnabledButtonField || field == &m_labelPointPickEnabledButtonField)
|
||||
{
|
||||
auto* pbAttribute = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>(attribute);
|
||||
if (pbAttribute)
|
||||
{
|
||||
auto boolField = static_cast<const caf::PdmField<bool>*>(field);
|
||||
if (boolField->v())
|
||||
{
|
||||
pbAttribute->m_buttonText = "Stop";
|
||||
}
|
||||
else
|
||||
{
|
||||
pbAttribute->m_buttonText = "Pick";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -84,7 +84,9 @@ private:
|
||||
QString extractNameFromText() const;
|
||||
|
||||
caf::PdmField<Vec3d> m_anchorPointXyd;
|
||||
caf::PdmField<bool> m_anchorPointPickEnabledButtonField;
|
||||
caf::PdmField<Vec3d> m_labelPointXyd;
|
||||
caf::PdmField<bool> m_labelPointPickEnabledButtonField;
|
||||
caf::PdmField<QString> m_text;
|
||||
caf::PdmField<bool> m_isActive;
|
||||
|
||||
|
||||
@@ -209,14 +209,6 @@ void RimUserDefinedPolylinesAnnotation::updateVisualization()
|
||||
void RimUserDefinedPolylinesAnnotation::enablePicking(bool enable)
|
||||
{
|
||||
m_enablePicking = enable;
|
||||
if (enable)
|
||||
{
|
||||
RiuViewerCommands::setPickEventHandler(m_pickTargetsEventHandler);
|
||||
}
|
||||
else
|
||||
{
|
||||
RiuViewerCommands::removePickEventHandlerIfActive(m_pickTargetsEventHandler);
|
||||
}
|
||||
updateConnectedEditors();
|
||||
}
|
||||
|
||||
@@ -259,7 +251,7 @@ void RimUserDefinedPolylinesAnnotation::fieldChangedByUi(const caf::PdmFieldHand
|
||||
{
|
||||
if (changedField == &m_enablePicking)
|
||||
{
|
||||
enablePicking(m_enablePicking);
|
||||
this->updateConnectedEditors();
|
||||
}
|
||||
else if (changedField == &m_showLines)
|
||||
{
|
||||
@@ -273,6 +265,19 @@ void RimUserDefinedPolylinesAnnotation::fieldChangedByUi(const caf::PdmFieldHand
|
||||
updateVisualization();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUserDefinedPolylinesAnnotation::defineObjectEditorAttribute(QString uiConfigName, caf::PdmUiEditorAttribute* attribute)
|
||||
{
|
||||
RicPolyline3dEditorAttribute* attrib = dynamic_cast<RicPolyline3dEditorAttribute*>(attribute);
|
||||
if (attrib)
|
||||
{
|
||||
attrib->pickEventHandler = m_pickTargetsEventHandler;
|
||||
attrib->enablePicking = m_enablePicking;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include "cafPdmFieldCvfVec3d.h"
|
||||
#include "cafPdmChildArrayField.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class RicPolylineTargetsPickEventHandler;
|
||||
class RimPolylineTarget;
|
||||
|
||||
@@ -59,6 +61,7 @@ protected:
|
||||
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName) override;
|
||||
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
void defineObjectEditorAttribute(QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override;
|
||||
|
||||
private:
|
||||
void defineCustomContextMenu(const caf::PdmFieldHandle* fieldNeedingMenu, QMenu* menu, QWidget* fieldEditorWidget) override;
|
||||
@@ -71,7 +74,8 @@ private:
|
||||
caf::PdmField<QString> m_name;
|
||||
caf::PdmField<bool> m_enablePicking;
|
||||
caf::PdmChildArrayField<RimPolylineTarget*> m_targets;
|
||||
RicPolylineTargetsPickEventHandler* m_pickTargetsEventHandler;
|
||||
|
||||
std::shared_ptr<RicPolylineTargetsPickEventHandler> m_pickTargetsEventHandler;
|
||||
};
|
||||
|
||||
|
||||
@@ -100,11 +100,6 @@ RimWellPathGeometryDef::RimWellPathGeometryDef()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellPathGeometryDef::~RimWellPathGeometryDef()
|
||||
{
|
||||
RiuViewerCommands::removePickEventHandlerIfActive(m_pickTargetsEventHandler);
|
||||
|
||||
delete m_pickTargetsEventHandler;
|
||||
|
||||
m_pickTargetsEventHandler = nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -290,18 +285,8 @@ const RimWellPathTarget* RimWellPathGeometryDef::lastActiveTarget() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellPathGeometryDef::enableTargetPointPicking(bool isEnabling)
|
||||
{
|
||||
if (isEnabling)
|
||||
{
|
||||
m_pickPointsEnabled = true;
|
||||
RiuViewerCommands::setPickEventHandler(m_pickTargetsEventHandler);
|
||||
updateConnectedEditors();
|
||||
}
|
||||
else
|
||||
{
|
||||
RiuViewerCommands::removePickEventHandlerIfActive(m_pickTargetsEventHandler);
|
||||
m_pickPointsEnabled = false;
|
||||
updateConnectedEditors();
|
||||
}
|
||||
m_pickPointsEnabled = isEnabling;
|
||||
this->updateConnectedEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -333,7 +318,7 @@ void RimWellPathGeometryDef::fieldChangedByUi(const caf::PdmFieldHandle* changed
|
||||
}
|
||||
else if (changedField == &m_pickPointsEnabled)
|
||||
{
|
||||
enableTargetPointPicking(m_pickPointsEnabled);
|
||||
this->updateConnectedEditors();
|
||||
}
|
||||
|
||||
updateWellPathVisualization();
|
||||
@@ -640,6 +625,19 @@ void RimWellPathGeometryDef::defineEditorAttribute(const caf::PdmFieldHandle* fi
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellPathGeometryDef::defineObjectEditorAttribute(QString uiConfigName, caf::PdmUiEditorAttribute* attribute)
|
||||
{
|
||||
RicWellPathGeometry3dEditorAttribute* attrib = dynamic_cast<RicWellPathGeometry3dEditorAttribute*>(attribute);
|
||||
if (attrib)
|
||||
{
|
||||
attrib->pickEventHandler = m_pickTargetsEventHandler;
|
||||
attrib->enablePicking = m_pickPointsEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -80,6 +80,9 @@ protected:
|
||||
|
||||
|
||||
|
||||
|
||||
virtual void defineObjectEditorAttribute(QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override;
|
||||
|
||||
private:
|
||||
void fieldChangedByUi(const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
@@ -101,11 +104,12 @@ private:
|
||||
caf::PdmChildArrayField<RimWellPathTarget*> m_wellTargets;
|
||||
|
||||
caf::PdmField< bool > m_pickPointsEnabled;
|
||||
RicCreateWellTargetsPickEventHandler* m_pickTargetsEventHandler;
|
||||
|
||||
// Unused for now. Remove when dust settles
|
||||
// TODO: Unused for now. Remove when dust settles
|
||||
|
||||
caf::PdmField<caf::AppEnum<WellStartType> > m_wellStartType;
|
||||
caf::PdmField<double> m_kickoffDepthOrMD;
|
||||
caf::PdmPtrField<RimWellPath*> m_parentWell;
|
||||
|
||||
std::shared_ptr<RicCreateWellTargetsPickEventHandler> m_pickTargetsEventHandler;
|
||||
};
|
||||
Reference in new issue
Block a user