mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-12 08:25:03 -05:00
Refactor PickEvent Hierarchy to have a basis in Caf
This commit is contained in:
1 parent
fad4dc91d7
commit
5d35678d97
5 files changed
+133
-8
No files matched your search
@@ -125,6 +125,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicExportFeatureImpl.cpp
|
|||||||
|
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicSelectOrCreateViewFeatureImpl.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RicSelectOrCreateViewFeatureImpl.cpp
|
||||||
|
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RicPickEventHandler.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicContourMapPickEventHandler.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RicContourMapPickEventHandler.cpp
|
||||||
|
|
||||||
# General delete of any object in a child array field
|
# General delete of any object in a child array field
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (C) 2019- 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 "RicPickEventHandler.h"
|
||||||
|
#include "RiuViewerCommands.h"
|
||||||
|
|
||||||
|
#include <typeinfo>
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicPickEventHandler::registerAsPickEventHandler()
|
||||||
|
{
|
||||||
|
RiuViewerCommands::setPickEventHandler(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicPickEventHandler::unregisterAsPickEventHandler()
|
||||||
|
{
|
||||||
|
RiuViewerCommands::removePickEventHandlerIfActive(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
/// Override from caf::PickEventHandler. Translates to a 3d Pick event.
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RicPickEventHandler::handlePickEvent(const caf::PickEvent& eventObject)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const Ric3DPickEvent& eventObject3d = dynamic_cast<const Ric3DPickEvent&>(eventObject);
|
||||||
|
return handlePickEvent(eventObject3d);
|
||||||
|
}
|
||||||
|
catch (const std::bad_cast&)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,12 +19,15 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "RiuPickItemInfo.h"
|
||||||
|
|
||||||
#include "cafCmdFeature.h"
|
#include "cafCmdFeature.h"
|
||||||
|
#include "cafPickEventHandler.h"
|
||||||
|
#include "cafPdmField.h"
|
||||||
|
|
||||||
#include "cvfBase.h"
|
#include "cvfBase.h"
|
||||||
#include "cvfObject.h"
|
#include "cvfObject.h"
|
||||||
#include "cvfVector3.h"
|
#include "cvfVector3.h"
|
||||||
#include "RiuPickItemInfo.h"
|
|
||||||
|
|
||||||
namespace cvf {
|
namespace cvf {
|
||||||
class Part;
|
class Part;
|
||||||
@@ -35,7 +38,7 @@ class Rim3dView;
|
|||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
///
|
///
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
class Ric3DPickEvent
|
class Ric3DPickEvent : public caf::PickEvent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Ric3DPickEvent(const std::vector<RiuPickItemInfo>& pickItemInfos,
|
Ric3DPickEvent(const std::vector<RiuPickItemInfo>& pickItemInfos,
|
||||||
@@ -62,10 +65,13 @@ public:
|
|||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
/// A temporary, dynamic pick handler that overrides the default ones
|
/// A temporary, dynamic pick handler that overrides the default ones
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
class RicPickEventHandler
|
class RicPickEventHandler : public caf::PickEventHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
// Override from caf
|
||||||
|
void registerAsPickEventHandler() override;
|
||||||
|
void unregisterAsPickEventHandler() override;
|
||||||
|
bool handlePickEvent(const caf::PickEvent& eventObject) override;
|
||||||
virtual bool handlePickEvent(const Ric3DPickEvent& eventObject) = 0;
|
virtual bool handlePickEvent(const Ric3DPickEvent& eventObject) = 0;
|
||||||
virtual void notifyUnregistered() = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -52,8 +52,8 @@ set (MOC_HEADER_FILES
|
|||||||
cafPdmUiTreeSelectionQModel.h
|
cafPdmUiTreeSelectionQModel.h
|
||||||
cafPdmUiFormLayoutObjectEditor.h
|
cafPdmUiFormLayoutObjectEditor.h
|
||||||
cafPdmUiDoubleValueEditor.h
|
cafPdmUiDoubleValueEditor.h
|
||||||
cafPdmUniqueIdValidator.h
|
cafPdmUniqueIdValidator.h
|
||||||
cafPdmDoubleStringValidator.h
|
cafPdmDoubleStringValidator.h
|
||||||
)
|
)
|
||||||
|
|
||||||
if ( NOT CMAKE_AUTOMOC )
|
if ( NOT CMAKE_AUTOMOC )
|
||||||
@@ -156,8 +156,9 @@ set( PROJECT_FILES
|
|||||||
cafQTreeViewStateSerializer.cpp
|
cafQTreeViewStateSerializer.cpp
|
||||||
cafMemoryInspector.h
|
cafMemoryInspector.h
|
||||||
cafMemoryInspector.cpp
|
cafMemoryInspector.cpp
|
||||||
cafPdmUniqueIdValidator.cpp
|
cafPdmUniqueIdValidator.cpp
|
||||||
cafPdmDoubleStringValidator.cpp
|
cafPdmDoubleStringValidator.cpp
|
||||||
|
cafPickEventHandler.h
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library( ${PROJECT_NAME}
|
add_library( ${PROJECT_NAME}
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
//##################################################################################################
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
//
|
||||||
|
//##################################################################################################
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace caf
|
||||||
|
{
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
/// Interface for Pick Events
|
||||||
|
//==================================================================================================
|
||||||
|
class PickEvent
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~PickEvent() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
/// Interface for Pick handlers
|
||||||
|
//==================================================================================================
|
||||||
|
class PickEventHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
Reference in new issue
Block a user