mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2163 Make intersection event handler
This commit is contained in:
parent
f7de89a584
commit
d5819eaad7
@ -77,55 +77,6 @@ void RicNewPolylineIntersectionFeature::setupActionLook(QAction* actionToSetup)
|
||||
actionToSetup->setText("New Polyline Intersection");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicNewPolylineIntersectionFeature::handleEvent(cvf::Object* eventObject)
|
||||
{
|
||||
std::vector<RimIntersection*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||
|
||||
if (selection.size() == 1)
|
||||
{
|
||||
RicViewerEventObject* polylineUiEvent = dynamic_cast<RicViewerEventObject*>(eventObject);
|
||||
if (polylineUiEvent)
|
||||
{
|
||||
RimIntersection* intersection = selection[0];
|
||||
|
||||
RimView* rimView = nullptr;
|
||||
intersection->firstAncestorOrThisOfType(rimView);
|
||||
CVF_ASSERT(rimView);
|
||||
|
||||
cvf::ref<caf::DisplayCoordTransform> transForm = rimView->displayCoordTransform();
|
||||
cvf::Vec3d domainCoord = transForm->transformToDomainCoord(polylineUiEvent->globalIntersectionPoint);
|
||||
|
||||
if (intersection->inputPolyLineFromViewerEnabled())
|
||||
{
|
||||
intersection->appendPointToPolyLine(domainCoord);
|
||||
|
||||
// Further Ui processing is stopped when true is returned
|
||||
return true;
|
||||
}
|
||||
else if (intersection->inputExtrusionPointsFromViewerEnabled())
|
||||
{
|
||||
intersection->appendPointToExtrusionDirection(domainCoord);
|
||||
|
||||
// Further Ui processing is stopped when true is returned
|
||||
return true;
|
||||
}
|
||||
else if (intersection->inputTwoAzimuthPointsFromViewerEnabled())
|
||||
{
|
||||
intersection->appendPointToAzimuthLine(domainCoord);
|
||||
|
||||
// Further Ui processing is stopped when true is returned
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -40,9 +40,9 @@ public:
|
||||
explicit RicNewPolylineIntersectionFeatureCmd(RimIntersectionCollection* intersectionCollection);
|
||||
virtual ~RicNewPolylineIntersectionFeatureCmd();
|
||||
|
||||
virtual QString name();
|
||||
virtual void redo();
|
||||
virtual void undo();
|
||||
virtual QString name() override;
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
|
||||
private:
|
||||
caf::PdmPointer<RimIntersectionCollection> m_intersectionCollection;
|
||||
@ -53,7 +53,7 @@ private:
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicNewPolylineIntersectionFeature : public caf::CmdFeature, public RicViewerEventInterface
|
||||
class RicNewPolylineIntersectionFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
@ -61,12 +61,9 @@ public:
|
||||
RicNewPolylineIntersectionFeature();
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
virtual bool isCommandEnabled();
|
||||
virtual void onActionTriggered( bool isChecked );
|
||||
virtual void setupActionLook( QAction* actionToSetup );
|
||||
|
||||
virtual bool handleEvent(cvf::Object* eventObject);
|
||||
virtual bool isCommandEnabled() override;
|
||||
virtual void onActionTriggered( bool isChecked ) override;
|
||||
virtual void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
||||
|
||||
|
||||
|
@ -11,6 +11,7 @@ ${CEE_CURRENT_LIST_DIR}RicWellPathsImportSsihubFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicWellPathsUnitSystemSettingsImpl.h
|
||||
${CEE_CURRENT_LIST_DIR}RicWellPathsUnitSystemSettingsUi.h
|
||||
${CEE_CURRENT_LIST_DIR}RicWellPathViewerEventHandler.h
|
||||
${CEE_CURRENT_LIST_DIR}RicIntersectionViewerEventHandler.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@ -20,6 +21,7 @@ ${CEE_CURRENT_LIST_DIR}RicWellPathsImportSsihubFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicWellPathsUnitSystemSettingsImpl.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicWellPathsUnitSystemSettingsUi.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicWellPathViewerEventHandler.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicIntersectionViewerEventHandler.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
@ -0,0 +1,85 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017- Statoil 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 "RicIntersectionViewerEventHandler.h"
|
||||
#include "RimIntersection.h"
|
||||
#include "RimView.h"
|
||||
|
||||
#include "cafDisplayCoordTransform.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicIntersectionViewerEventHandler* RicIntersectionViewerEventHandler::instance()
|
||||
{
|
||||
static RicIntersectionViewerEventHandler* singleton = new RicIntersectionViewerEventHandler;
|
||||
return singleton;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicIntersectionViewerEventHandler::handleEvent(cvf::Object* eventObject)
|
||||
{
|
||||
std::vector<RimIntersection*> selection;
|
||||
caf::SelectionManager::instance()->objectsByType(&selection);
|
||||
|
||||
if (selection.size() == 1)
|
||||
{
|
||||
RicViewerEventObject* polylineUiEvent = dynamic_cast<RicViewerEventObject*>(eventObject);
|
||||
if (polylineUiEvent)
|
||||
{
|
||||
RimIntersection* intersection = selection[0];
|
||||
|
||||
RimView* rimView = nullptr;
|
||||
intersection->firstAncestorOrThisOfType(rimView);
|
||||
CVF_ASSERT(rimView);
|
||||
|
||||
cvf::ref<caf::DisplayCoordTransform> transForm = rimView->displayCoordTransform();
|
||||
cvf::Vec3d domainCoord = transForm->transformToDomainCoord(polylineUiEvent->globalIntersectionPoint);
|
||||
|
||||
if (intersection->inputPolyLineFromViewerEnabled())
|
||||
{
|
||||
intersection->appendPointToPolyLine(domainCoord);
|
||||
|
||||
// Further Ui processing is stopped when true is returned
|
||||
return true;
|
||||
}
|
||||
else if (intersection->inputExtrusionPointsFromViewerEnabled())
|
||||
{
|
||||
intersection->appendPointToExtrusionDirection(domainCoord);
|
||||
|
||||
// Further Ui processing is stopped when true is returned
|
||||
return true;
|
||||
}
|
||||
else if (intersection->inputTwoAzimuthPointsFromViewerEnabled())
|
||||
{
|
||||
intersection->appendPointToAzimuthLine(domainCoord);
|
||||
|
||||
// Further Ui processing is stopped when true is returned
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017- Statoil 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RicViewerEventInterface.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicIntersectionViewerEventHandler : public RicViewerEventInterface
|
||||
{
|
||||
public:
|
||||
static RicIntersectionViewerEventHandler* instance();
|
||||
|
||||
protected:
|
||||
virtual bool handleEvent(cvf::Object* eventObject) override;
|
||||
};
|
||||
|
@ -22,10 +22,11 @@
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaColorTables.h"
|
||||
|
||||
#include "RicViewerEventInterface.h"
|
||||
#include "RicEclipsePropertyFilterNewExec.h"
|
||||
#include "RicGeoMechPropertyFilterNewExec.h"
|
||||
#include "RicRangeFilterNewExec.h"
|
||||
#include "RicViewerEventInterface.h"
|
||||
#include "WellPathCommands/RicIntersectionViewerEventHandler.h"
|
||||
#include "WellPathCommands/RicWellPathViewerEventHandler.h"
|
||||
|
||||
#include "RigEclipseCaseData.h"
|
||||
@ -106,10 +107,7 @@ RiuViewerCommands::RiuViewerCommands(RiuViewer* ownerViewer)
|
||||
m_currentPickPositionInDomainCoords(cvf::Vec3d::UNDEFINED)
|
||||
{
|
||||
{
|
||||
caf::CmdFeature* cmdFeature = caf::CmdFeatureManager::instance()->getCommandFeature("RicNewPolylineIntersectionFeature");
|
||||
CVF_ASSERT(cmdFeature);
|
||||
|
||||
m_viewerEventHandlers.push_back(dynamic_cast<RicViewerEventInterface*>(cmdFeature));
|
||||
m_viewerEventHandlers.push_back(dynamic_cast<RicViewerEventInterface*>(RicIntersectionViewerEventHandler::instance()));
|
||||
}
|
||||
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user