mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Refactor PickEvent Hierarchy to have a basis in Caf
This commit is contained in:
parent
fad4dc91d7
commit
5d35678d97
@ -125,6 +125,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicExportFeatureImpl.cpp
|
||||
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicSelectOrCreateViewFeatureImpl.cpp
|
||||
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicPickEventHandler.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicContourMapPickEventHandler.cpp
|
||||
|
||||
# General delete of any object in a child array field
|
||||
|
53
ApplicationCode/Commands/RicPickEventHandler.cpp
Normal file
53
ApplicationCode/Commands/RicPickEventHandler.cpp
Normal file
@ -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
|
||||
|
||||
#include "RiuPickItemInfo.h"
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
#include "cafPickEventHandler.h"
|
||||
#include "cafPdmField.h"
|
||||
|
||||
#include "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cvfVector3.h"
|
||||
#include "RiuPickItemInfo.h"
|
||||
|
||||
namespace cvf {
|
||||
class Part;
|
||||
@ -35,7 +38,7 @@ class Rim3dView;
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class Ric3DPickEvent
|
||||
class Ric3DPickEvent : public caf::PickEvent
|
||||
{
|
||||
public:
|
||||
Ric3DPickEvent(const std::vector<RiuPickItemInfo>& pickItemInfos,
|
||||
@ -62,10 +65,13 @@ public:
|
||||
//==================================================================================================
|
||||
/// A temporary, dynamic pick handler that overrides the default ones
|
||||
//==================================================================================================
|
||||
class RicPickEventHandler
|
||||
class RicPickEventHandler : public caf::PickEventHandler
|
||||
{
|
||||
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 void notifyUnregistered() = 0;
|
||||
};
|
||||
|
||||
|
@ -52,8 +52,8 @@ set (MOC_HEADER_FILES
|
||||
cafPdmUiTreeSelectionQModel.h
|
||||
cafPdmUiFormLayoutObjectEditor.h
|
||||
cafPdmUiDoubleValueEditor.h
|
||||
cafPdmUniqueIdValidator.h
|
||||
cafPdmDoubleStringValidator.h
|
||||
cafPdmUniqueIdValidator.h
|
||||
cafPdmDoubleStringValidator.h
|
||||
)
|
||||
|
||||
if ( NOT CMAKE_AUTOMOC )
|
||||
@ -156,8 +156,9 @@ set( PROJECT_FILES
|
||||
cafQTreeViewStateSerializer.cpp
|
||||
cafMemoryInspector.h
|
||||
cafMemoryInspector.cpp
|
||||
cafPdmUniqueIdValidator.cpp
|
||||
cafPdmDoubleStringValidator.cpp
|
||||
cafPdmUniqueIdValidator.cpp
|
||||
cafPdmDoubleStringValidator.cpp
|
||||
cafPickEventHandler.h
|
||||
)
|
||||
|
||||
add_library( ${PROJECT_NAME}
|
||||
|
64
Fwk/AppFwk/cafUserInterface/cafPickEventHandler.h
Normal file
64
Fwk/AppFwk/cafUserInterface/cafPickEventHandler.h
Normal file
@ -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;
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user