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:
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user