mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4045 Don't accept pick events if the current selected object isn't the object owning the pick handler.
This commit is contained in:
parent
dbe21b7809
commit
c4f5065032
@ -43,6 +43,13 @@ RicMeasurementPickEventHandler* RicMeasurementPickEventHandler::instance()
|
||||
return singleton;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicMeasurementPickEventHandler::RicMeasurementPickEventHandler()
|
||||
: Ric3dViewPickEventHandler(nullptr)
|
||||
{}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -29,6 +29,7 @@ public:
|
||||
static RicMeasurementPickEventHandler* instance();
|
||||
|
||||
protected:
|
||||
RicMeasurementPickEventHandler();
|
||||
bool handle3dPickEvent(const Ric3dPickEvent& eventObject) override;
|
||||
void notifyUnregistered() override;
|
||||
};
|
||||
|
@ -20,6 +20,13 @@
|
||||
|
||||
#include <typeinfo>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
Ric3dViewPickEventHandler::Ric3dViewPickEventHandler(const caf::PdmObjectHandle* handlingObject)
|
||||
: caf::PickEventHandler(handlingObject)
|
||||
{}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "RicPickEventHandler.h"
|
||||
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObjectHandle.h"
|
||||
|
||||
//==================================================================================================
|
||||
/// A temporary, dynamic pick handler that overrides the default ones
|
||||
@ -27,11 +28,14 @@
|
||||
class Ric3dViewPickEventHandler : public caf::PickEventHandler
|
||||
{
|
||||
public:
|
||||
Ric3dViewPickEventHandler(const caf::PdmObjectHandle* handlingObject);
|
||||
|
||||
// Override from caf
|
||||
void registerAsPickEventHandler() override;
|
||||
void unregisterAsPickEventHandler() override;
|
||||
bool handlePickEvent(const caf::PickEvent& eventObject) override;
|
||||
virtual bool handle3dPickEvent(const Ric3dPickEvent& eventObject) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -20,12 +20,15 @@
|
||||
#include "Rim3dView.h"
|
||||
|
||||
#include "cafDisplayCoordTransform.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicVec3dPickEventHandler::RicVec3dPickEventHandler(caf::PdmField<cvf::Vec3d>* vectorField)
|
||||
: m_vectorField(vectorField)
|
||||
RicVec3dPickEventHandler::RicVec3dPickEventHandler(const caf::PdmObjectHandle* handlingObject,
|
||||
caf::PdmField<cvf::Vec3d>* vectorField)
|
||||
: Ric3dViewPickEventHandler(handlingObject)
|
||||
, m_vectorField(vectorField)
|
||||
{
|
||||
}
|
||||
|
||||
@ -34,14 +37,19 @@ RicVec3dPickEventHandler::RicVec3dPickEventHandler(caf::PdmField<cvf::Vec3d>* ve
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicVec3dPickEventHandler::handle3dPickEvent(const Ric3dPickEvent& eventObject)
|
||||
{
|
||||
const Rim3dView* rimView = eventObject.m_view;
|
||||
caf::PdmObjectHandle* selectedObject = caf::SelectionManager::instance()->selectedItemOfType<caf::PdmObjectHandle>();
|
||||
if (isObjectBeingModified(selectedObject))
|
||||
{
|
||||
const Rim3dView* rimView = eventObject.m_view;
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -29,7 +29,7 @@ class Rim3dView;
|
||||
class RicVec3dPickEventHandler : public Ric3dViewPickEventHandler
|
||||
{
|
||||
public:
|
||||
RicVec3dPickEventHandler(caf::PdmField<cvf::Vec3d>* vectorField);
|
||||
RicVec3dPickEventHandler(const caf::PdmObjectHandle* handlingObject, caf::PdmField<cvf::Vec3d>* vectorField);
|
||||
bool handle3dPickEvent(const Ric3dPickEvent& eventObject) override;
|
||||
void notifyUnregistered() override;
|
||||
|
||||
|
@ -55,7 +55,7 @@
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicCreateWellTargetsPickEventHandler::RicCreateWellTargetsPickEventHandler(RimWellPathGeometryDef* wellGeometryDef)
|
||||
: m_geometryToAddTargetsTo(wellGeometryDef)
|
||||
: Ric3dViewPickEventHandler(wellGeometryDef), m_geometryToAddTargetsTo(wellGeometryDef)
|
||||
{
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ void RicCreateWellTargetsPickEventHandler::notifyUnregistered()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicCreateWellTargetsPickEventHandler::handle3dPickEvent(const Ric3dPickEvent& eventObject)
|
||||
{
|
||||
if (!caf::SelectionManager::instance()->isSelected(m_geometryToAddTargetsTo.p(), 0))
|
||||
if (!isObjectBeingModified(caf::SelectionManager::instance()->selectedItemOfType<caf::PdmObjectHandle>()))
|
||||
{
|
||||
m_geometryToAddTargetsTo->enableTargetPointPicking(false);
|
||||
|
||||
|
@ -40,7 +40,7 @@
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicPolylineTargetsPickEventHandler::RicPolylineTargetsPickEventHandler(RimUserDefinedPolylinesAnnotation* polylineDef)
|
||||
: m_polylineDef(polylineDef)
|
||||
: Ric3dViewPickEventHandler(polylineDef), m_polylineDef(polylineDef)
|
||||
{
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ void RicPolylineTargetsPickEventHandler::notifyUnregistered()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicPolylineTargetsPickEventHandler::handle3dPickEvent(const Ric3dPickEvent& eventObject)
|
||||
{
|
||||
if (!caf::SelectionManager::instance()->isSelected(m_polylineDef.p(), 0))
|
||||
if (!isObjectBeingModified(caf::SelectionManager::instance()->selectedItemOfType<caf::PdmObjectHandle>()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ RimReachCircleAnnotation::RimReachCircleAnnotation()
|
||||
m_appearance.uiCapability()->setUiTreeHidden(true);
|
||||
m_appearance.uiCapability()->setUiTreeChildrenHidden(true);
|
||||
|
||||
m_centerPointEventHandler.reset(new RicVec3dPickEventHandler(&m_centerPointXyd));
|
||||
m_centerPointEventHandler.reset(new RicVec3dPickEventHandler(this, &m_centerPointXyd));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -67,8 +67,8 @@ RimTextAnnotation::RimTextAnnotation()
|
||||
m_nameProxy.uiCapability()->setUiReadOnly(true);
|
||||
m_nameProxy.xmlCapability()->disableIO();
|
||||
|
||||
m_anchorPointPickEventHandler.reset(new RicVec3dPickEventHandler(&m_anchorPointXyd));
|
||||
m_labelPointPickEventHandler.reset(new RicVec3dPickEventHandler(&m_labelPointXyd));
|
||||
m_anchorPointPickEventHandler.reset(new RicVec3dPickEventHandler(this, &m_anchorPointXyd));
|
||||
m_labelPointPickEventHandler.reset(new RicVec3dPickEventHandler(this, &m_labelPointXyd));
|
||||
|
||||
}
|
||||
|
||||
|
@ -159,6 +159,7 @@ set( PROJECT_FILES
|
||||
cafPdmUniqueIdValidator.cpp
|
||||
cafPdmDoubleStringValidator.cpp
|
||||
cafPickEventHandler.h
|
||||
cafPickEventHandler.cpp
|
||||
)
|
||||
|
||||
add_library( ${PROJECT_NAME}
|
||||
|
44
Fwk/AppFwk/cafUserInterface/cafPickEventHandler.cpp
Normal file
44
Fwk/AppFwk/cafUserInterface/cafPickEventHandler.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
//##################################################################################################
|
||||
//
|
||||
// Custom Visualization Core library
|
||||
// Copyright (C) 2019- Ceetron Solution AS
|
||||
//
|
||||
// This library may be used under the terms of either the GNU General Public License or
|
||||
// the GNU Lesser General Public License as follows:
|
||||
//
|
||||
// GNU General Public License Usage
|
||||
// This library 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.
|
||||
//
|
||||
// This library 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.
|
||||
//
|
||||
// GNU Lesser General Public License Usage
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
|
||||
// for more details.
|
||||
//
|
||||
//##################################################################################################
|
||||
#include "cafPickEventHandler.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool caf::PickEventHandler::isObjectBeingModified(const PdmObjectHandle* object) const
|
||||
{
|
||||
return m_objectBeingModified == object;
|
||||
}
|
@ -36,6 +36,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmObjectHandle.h"
|
||||
|
||||
namespace caf
|
||||
{
|
||||
|
||||
@ -54,11 +56,18 @@ public:
|
||||
class PickEventHandler
|
||||
{
|
||||
public:
|
||||
PickEventHandler(const PdmObjectHandle* objectBeingModified) : m_objectBeingModified(objectBeingModified) {}
|
||||
|
||||
bool isObjectBeingModified(const PdmObjectHandle* testObject) const;
|
||||
|
||||
virtual void registerAsPickEventHandler() = 0;
|
||||
virtual void unregisterAsPickEventHandler() = 0;
|
||||
// TODO: Rename to just handlePickEvent when the RicPickEventHandler::handlePickEvent has been renamed
|
||||
virtual bool handlePickEvent(const PickEvent& eventObject) = 0;
|
||||
virtual void notifyUnregistered() = 0;
|
||||
|
||||
private:
|
||||
const PdmObjectHandle* m_objectBeingModified;
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user