2015-12-04 08:15:13 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// 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"
|
|
|
|
|
2018-01-09 03:11:28 -06:00
|
|
|
#include "Rim3dView.h"
|
2018-02-02 01:20:54 -06:00
|
|
|
#include "RimPerforationInterval.h"
|
2015-12-04 08:15:13 -06:00
|
|
|
#include "RimWellPath.h"
|
2018-03-20 09:32:32 -05:00
|
|
|
#include "Rim2dIntersectionView.h"
|
2016-11-02 08:44:35 -05:00
|
|
|
|
2015-12-04 08:15:13 -06:00
|
|
|
#include "RiuMainWindow.h"
|
|
|
|
|
2018-01-12 00:54:37 -06:00
|
|
|
#include "RivObjectSourceInfo.h"
|
2015-12-04 08:15:13 -06:00
|
|
|
#include "RivWellPathSourceInfo.h"
|
|
|
|
|
2016-11-02 08:44:35 -05:00
|
|
|
#include "cafDisplayCoordTransform.h"
|
|
|
|
|
2015-12-04 08:15:13 -06:00
|
|
|
#include "cvfPart.h"
|
|
|
|
#include "cvfVector3.h"
|
2018-03-20 09:32:32 -05:00
|
|
|
#include "RivIntersectionPartMgr.h"
|
2015-12-04 08:15:13 -06:00
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RicWellPathViewerEventHandler* RicWellPathViewerEventHandler::instance()
|
|
|
|
{
|
|
|
|
static RicWellPathViewerEventHandler* singleton = new RicWellPathViewerEventHandler;
|
|
|
|
return singleton;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-01-12 00:54:37 -06:00
|
|
|
bool RicWellPathViewerEventHandler::handleEvent(const RicViewerEventObject& eventObject)
|
2015-12-04 08:15:13 -06:00
|
|
|
{
|
2018-01-12 00:54:37 -06:00
|
|
|
if (eventObject.m_partAndTriangleIndexPairs.empty()) return false;
|
2015-12-04 08:15:13 -06:00
|
|
|
|
2018-01-12 00:54:37 -06:00
|
|
|
const caf::PdmObject* objectToSelect = nullptr;
|
|
|
|
|
|
|
|
cvf::uint wellPathTriangleIndex = cvf::UNDEFINED_UINT;
|
|
|
|
const RivWellPathSourceInfo* wellPathSourceInfo = nullptr;
|
2018-01-23 07:13:45 -06:00
|
|
|
|
2018-02-02 01:20:54 -06:00
|
|
|
if(!eventObject.m_partAndTriangleIndexPairs.empty())
|
2015-12-04 08:15:13 -06:00
|
|
|
{
|
2018-01-23 07:13:45 -06:00
|
|
|
const auto & partAndTriangleIndexPair = eventObject.m_partAndTriangleIndexPairs.front();
|
2018-01-12 00:54:37 -06:00
|
|
|
const cvf::Part* part = partAndTriangleIndexPair.first;
|
|
|
|
|
|
|
|
const RivObjectSourceInfo* sourceInfo = dynamic_cast<const RivObjectSourceInfo*>(part->sourceInfo());
|
2018-02-02 01:20:54 -06:00
|
|
|
if (sourceInfo)
|
2015-12-04 08:15:13 -06:00
|
|
|
{
|
2018-02-02 01:20:54 -06:00
|
|
|
if (dynamic_cast<RimPerforationInterval*>(sourceInfo->object()))
|
|
|
|
{
|
|
|
|
objectToSelect = sourceInfo->object();
|
|
|
|
|
|
|
|
if (eventObject.m_partAndTriangleIndexPairs.size() > 1)
|
|
|
|
{
|
|
|
|
const auto& secondPair = eventObject.m_partAndTriangleIndexPairs[1];
|
|
|
|
const cvf::Part* secondPickedPart = secondPair.first;
|
|
|
|
if (secondPickedPart)
|
|
|
|
{
|
|
|
|
auto wellPathSourceCandidate = dynamic_cast<const RivWellPathSourceInfo*>(secondPickedPart->sourceInfo());
|
|
|
|
if (wellPathSourceCandidate)
|
|
|
|
{
|
|
|
|
RimWellPath* perforationWellPath = nullptr;
|
|
|
|
objectToSelect->firstAncestorOrThisOfType(perforationWellPath);
|
|
|
|
if (perforationWellPath == wellPathSourceCandidate->wellPath())
|
|
|
|
{
|
|
|
|
wellPathSourceInfo = dynamic_cast<const RivWellPathSourceInfo*>(secondPickedPart->sourceInfo());
|
|
|
|
wellPathTriangleIndex = secondPair.second;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-01-12 00:54:37 -06:00
|
|
|
}
|
2015-12-04 08:15:13 -06:00
|
|
|
|
2018-02-02 01:20:54 -06:00
|
|
|
if (part && dynamic_cast<const RivWellPathSourceInfo*>(part->sourceInfo()))
|
2018-01-12 00:54:37 -06:00
|
|
|
{
|
|
|
|
wellPathSourceInfo = dynamic_cast<const RivWellPathSourceInfo*>(part->sourceInfo());
|
|
|
|
wellPathTriangleIndex = partAndTriangleIndexPair.second;
|
|
|
|
}
|
|
|
|
}
|
2015-12-04 08:15:13 -06:00
|
|
|
|
2018-01-12 00:54:37 -06:00
|
|
|
if (wellPathSourceInfo)
|
|
|
|
{
|
|
|
|
Rim3dView* rimView = RiaApplication::instance()->activeReservoirView();
|
|
|
|
if (!rimView) return false;
|
2017-02-02 00:36:22 -06:00
|
|
|
|
2018-01-12 00:54:37 -06:00
|
|
|
cvf::ref<caf::DisplayCoordTransform> transForm = rimView->displayCoordTransform();
|
|
|
|
cvf::Vec3d domainCoord = transForm->transformToDomainCoord(eventObject.m_globalIntersectionPoint);
|
2015-12-04 08:15:13 -06:00
|
|
|
|
2018-03-20 09:32:32 -05:00
|
|
|
auto intersectionView = dynamic_cast<Rim2dIntersectionView*>(rimView);
|
|
|
|
if (intersectionView)
|
|
|
|
{
|
|
|
|
cvf::Mat4d unflatXf = intersectionView->flatIntersectionPartMgr()->unflattenTransformMatrix(domainCoord);
|
|
|
|
if (!unflatXf.isZero())
|
|
|
|
{
|
|
|
|
domainCoord = domainCoord.getTransformedPoint(unflatXf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-12 00:54:37 -06:00
|
|
|
double measuredDepth = wellPathSourceInfo->measuredDepth(wellPathTriangleIndex, domainCoord);
|
2015-12-04 08:15:13 -06:00
|
|
|
|
2018-01-12 00:54:37 -06:00
|
|
|
// NOTE: This computation was used to find the location for a fracture when clicking on a well path
|
|
|
|
// It turned out that the computation was a bit inaccurate
|
|
|
|
// Consider to use code in RigSimulationWellCoordsAndMD instead
|
|
|
|
cvf::Vec3d trueVerticalDepth = wellPathSourceInfo->trueVerticalDepth(wellPathTriangleIndex, domainCoord);
|
2015-12-04 08:15:13 -06:00
|
|
|
|
2018-01-12 00:54:37 -06:00
|
|
|
QString wellPathText;
|
|
|
|
wellPathText += QString("Well path name : %1\n").arg(wellPathSourceInfo->wellPath()->name());
|
|
|
|
wellPathText += QString("Measured depth : %1\n").arg(measuredDepth);
|
2015-12-04 08:15:13 -06:00
|
|
|
|
2018-01-12 00:54:37 -06:00
|
|
|
QString formattedText;
|
|
|
|
formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", trueVerticalDepth.x(), trueVerticalDepth.y(), -trueVerticalDepth.z());
|
|
|
|
wellPathText += formattedText;
|
2015-12-16 02:45:56 -06:00
|
|
|
|
2018-01-12 00:54:37 -06:00
|
|
|
RiuMainWindow::instance()->setResultInfo(wellPathText);
|
|
|
|
|
|
|
|
if (objectToSelect)
|
|
|
|
{
|
|
|
|
RiuMainWindow::instance()->selectAsCurrentItem(objectToSelect);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RiuMainWindow::instance()->selectAsCurrentItem(wellPathSourceInfo->wellPath());
|
2015-12-04 08:15:13 -06:00
|
|
|
}
|
2018-01-12 00:54:37 -06:00
|
|
|
|
|
|
|
return true;
|
2015-12-04 08:15:13 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|