mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Simplify pick event system
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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,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;
|
||||
|
||||
Reference in New Issue
Block a user