(#404) Added RicViewerEventInterface and moved well path text display into a separate class

This commit is contained in:
Magne Sjaastad
2015-12-04 15:15:13 +01:00
parent 27206cab3b
commit e65facd590
9 changed files with 177 additions and 70 deletions

View File

@@ -78,14 +78,14 @@ void RicNewPolylineCrossSectionFeature::setupActionLook(QAction* actionToSetup)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewPolylineCrossSectionFeature::handleUiEvent(cvf::Object* uiEventObject)
bool RicNewPolylineCrossSectionFeature::handleEvent(cvf::Object* eventObject)
{
std::vector<RimCrossSection*> selection;
caf::SelectionManager::instance()->objectsByType(&selection);
if (selection.size() == 1)
{
RicLocalIntersectionUiEvent* polylineUiEvent = dynamic_cast<RicLocalIntersectionUiEvent*>(uiEventObject);
RicViewerEventObject* polylineUiEvent = dynamic_cast<RicViewerEventObject*>(eventObject);
if (polylineUiEvent)
{
RimCrossSection* crossSection = selection[0];

View File

@@ -19,7 +19,7 @@
#pragma once
#include "RicCommandFeature.h"
#include "RicViewerEventInterface.h"
#include "cafCmdExecuteCommand.h"
#include "cafPdmPointer.h"
@@ -53,7 +53,7 @@ private:
//==================================================================================================
///
//==================================================================================================
class RicNewPolylineCrossSectionFeature : public RicCommandFeature
class RicNewPolylineCrossSectionFeature : public caf::CmdFeature, public RicViewerEventInterface
{
CAF_CMD_HEADER_INIT;
@@ -66,7 +66,7 @@ protected:
virtual void onActionTriggered( bool isChecked );
virtual void setupActionLook( QAction* actionToSetup );
virtual bool handleUiEvent(cvf::Object* uiEventObject);
virtual bool handleEvent(cvf::Object* eventObject);
};

View File

@@ -0,0 +1,53 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// 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 "cafCmdFeature.h"
#include "cvfBase.h"
#include "cvfObject.h"
#include "cvfVector3.h"
namespace cvf {
class Part;
}
class RicViewerEventInterface
{
public:
virtual bool handleEvent(cvf::Object* eventObject) = 0;
};
class RicViewerEventObject : public cvf::Object
{
public:
RicViewerEventObject(cvf::Vec3d localIntersectionPoint, cvf::Part* firstHitPart, cvf::uint firstPartTriangleIndex)
: localIntersectionPoint(localIntersectionPoint),
firstHitPart(firstHitPart),
firstPartTriangleIndex(firstPartTriangleIndex)
{
}
cvf::Vec3d localIntersectionPoint;
cvf::Part* firstHitPart;
cvf::uint firstPartTriangleIndex;
};

View File

@@ -9,6 +9,7 @@ ${CEE_CURRENT_LIST_DIR}RicWellPathDeleteFeature.h
${CEE_CURRENT_LIST_DIR}RicWellPathsDeleteAllFeature.h
${CEE_CURRENT_LIST_DIR}RicWellPathsImportFileFeature.h
${CEE_CURRENT_LIST_DIR}RicWellPathsImportSsihubFeature.h
${CEE_CURRENT_LIST_DIR}RicWellPathViewerEventHandler.h
)
set (SOURCE_GROUP_SOURCE_FILES
@@ -16,6 +17,7 @@ ${CEE_CURRENT_LIST_DIR}RicWellPathDeleteFeature.cpp
${CEE_CURRENT_LIST_DIR}RicWellPathsDeleteAllFeature.cpp
${CEE_CURRENT_LIST_DIR}RicWellPathsImportFileFeature.cpp
${CEE_CURRENT_LIST_DIR}RicWellPathsImportSsihubFeature.cpp
${CEE_CURRENT_LIST_DIR}RicWellPathViewerEventHandler.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@@ -0,0 +1,92 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// 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 "RicWellPathViewerEventHandler.h"
#include "RiaApplication.h"
#include "RimCase.h"
#include "RimView.h"
#include "RimWellPath.h"
#include "RiuMainWindow.h"
#include "RivWellPathSourceInfo.h"
#include "cvfPart.h"
#include "cvfVector3.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicWellPathViewerEventHandler* RicWellPathViewerEventHandler::instance()
{
static RicWellPathViewerEventHandler* singleton = new RicWellPathViewerEventHandler;
return singleton;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicWellPathViewerEventHandler::handleEvent(cvf::Object* eventObject)
{
RicViewerEventObject* uiEvent = dynamic_cast<RicViewerEventObject*>(eventObject);
if (!uiEvent) return false;
if (uiEvent->firstHitPart && uiEvent->firstHitPart->sourceInfo())
{
const RivWellPathSourceInfo* wellPathSourceInfo = dynamic_cast<const RivWellPathSourceInfo*>(uiEvent->firstHitPart->sourceInfo());
if (wellPathSourceInfo)
{
cvf::Vec3d displayModelOffset = cvf::Vec3d::ZERO;
RimView* activeView = RiaApplication::instance()->activeReservoirView();
if (!activeView) return false;
RimCase* rimCase = NULL;
activeView->firstAnchestorOrThisOfType(rimCase);
if (rimCase)
{
displayModelOffset = rimCase->displayModelOffset();
}
cvf::Vec3d unscaledIntersection = uiEvent->localIntersectionPoint;
unscaledIntersection.z() /= activeView->scaleZ;
size_t wellSegmentIndex = wellPathSourceInfo->segmentIndex(uiEvent->firstPartTriangleIndex);
double measuredDepth = wellPathSourceInfo->measuredDepth(uiEvent->firstPartTriangleIndex, unscaledIntersection + displayModelOffset);
cvf::Vec3d trueVerticalDepth = wellPathSourceInfo->trueVerticalDepth(uiEvent->firstPartTriangleIndex, unscaledIntersection + displayModelOffset);
QString wellPathText;
wellPathText += QString("Well path name : %1\n").arg(wellPathSourceInfo->wellPath()->name);
wellPathText += QString("Measured depth : %1\n").arg(measuredDepth);
QString formattedText;
formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", trueVerticalDepth.x(), trueVerticalDepth.y(), -trueVerticalDepth.z());
wellPathText += formattedText;
RiuMainWindow::instance()->setResultInfo(wellPathText);
return true;
}
}
return false;
}

View File

@@ -19,27 +19,17 @@
#pragma once
#include "cafCmdFeature.h"
#include "cvfBase.h"
#include "cvfObject.h"
#include "cvfVector3.h"
#include "RicViewerEventInterface.h"
class RicCommandFeature : public caf::CmdFeature
//==================================================================================================
///
//==================================================================================================
class RicWellPathViewerEventHandler : public RicViewerEventInterface
{
public:
virtual bool handleUiEvent(cvf::Object* uiEventObject) = 0;
};
class RicLocalIntersectionUiEvent : public cvf::Object
{
public:
RicLocalIntersectionUiEvent(cvf::Vec3d localIntersectionPoint)
: localIntersectionPoint(localIntersectionPoint)
{
}
cvf::Vec3d localIntersectionPoint;
static RicWellPathViewerEventHandler* instance();
virtual bool handleEvent(cvf::Object* eventObject);
};