mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#949 Intersection : Convert coordinates using DisplayCoordTransform
This commit is contained in:
@@ -28,8 +28,10 @@
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
#include "RiuSelectionManager.h"
|
||||
#include "RiuViewer.h"
|
||||
|
||||
#include "cafCmdExecCommandManager.h"
|
||||
#include "cafDisplayCoordTransform.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include "cvfAssert.h"
|
||||
@@ -90,20 +92,24 @@ bool RicNewPolylineIntersectionFeature::handleEvent(cvf::Object* eventObject)
|
||||
{
|
||||
RimIntersection* intersection = selection[0];
|
||||
|
||||
RimCase* rimCase = NULL;
|
||||
intersection->firstAncestorOrThisOfType(rimCase);
|
||||
CVF_ASSERT(rimCase);
|
||||
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(rimCase->displayModelOffset() + polylineUiEvent->localIntersectionPoint);
|
||||
intersection->appendPointToPolyLine(domainCoord);
|
||||
|
||||
// Further Ui processing is stopped when true is returned
|
||||
return true;
|
||||
}
|
||||
else if (intersection->inputExtrusionPointsFromViewerEnabled())
|
||||
{
|
||||
intersection->appendPointToExtrusionDirection(rimCase->displayModelOffset() + polylineUiEvent->localIntersectionPoint);
|
||||
|
||||
intersection->appendPointToExtrusionDirection(domainCoord);
|
||||
|
||||
// Further Ui processing is stopped when true is returned
|
||||
return true;
|
||||
|
||||
@@ -39,14 +39,14 @@ public:
|
||||
class RicViewerEventObject : public cvf::Object
|
||||
{
|
||||
public:
|
||||
RicViewerEventObject(cvf::Vec3d localIntersectionPoint, cvf::Part* firstHitPart, cvf::uint firstPartTriangleIndex)
|
||||
: localIntersectionPoint(localIntersectionPoint),
|
||||
RicViewerEventObject(cvf::Vec3d globalIntersectionPoint, cvf::Part* firstHitPart, cvf::uint firstPartTriangleIndex)
|
||||
: globalIntersectionPoint(globalIntersectionPoint),
|
||||
firstHitPart(firstHitPart),
|
||||
firstPartTriangleIndex(firstPartTriangleIndex)
|
||||
{
|
||||
}
|
||||
|
||||
cvf::Vec3d localIntersectionPoint;
|
||||
cvf::Vec3d globalIntersectionPoint;
|
||||
cvf::Part* firstHitPart;
|
||||
cvf::uint firstPartTriangleIndex;
|
||||
};
|
||||
|
||||
@@ -24,10 +24,13 @@
|
||||
#include "RimCase.h"
|
||||
#include "RimView.h"
|
||||
#include "RimWellPath.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
#include "RivWellPathSourceInfo.h"
|
||||
|
||||
#include "cafDisplayCoordTransform.h"
|
||||
|
||||
#include "cvfPart.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
@@ -56,21 +59,14 @@ bool RicWellPathViewerEventHandler::handleEvent(cvf::Object* eventObject)
|
||||
{
|
||||
cvf::Vec3d displayModelOffset = cvf::Vec3d::ZERO;
|
||||
|
||||
RimView* activeView = RiaApplication::instance()->activeReservoirView();
|
||||
if (!activeView) return false;
|
||||
RimView* rimView = RiaApplication::instance()->activeReservoirView();
|
||||
if (!rimView) return false;
|
||||
|
||||
RimCase* rimCase = NULL;
|
||||
activeView->firstAncestorOrThisOfType(rimCase);
|
||||
if (rimCase)
|
||||
{
|
||||
displayModelOffset = rimCase->displayModelOffset();
|
||||
}
|
||||
cvf::ref<caf::DisplayCoordTransform> transForm = rimView->displayCoordTransform();
|
||||
cvf::Vec3d domainCoord = transForm->transformToDomainCoord(uiEvent->globalIntersectionPoint);
|
||||
|
||||
cvf::Vec3d unscaledIntersection = uiEvent->localIntersectionPoint;
|
||||
unscaledIntersection.z() /= activeView->scaleZ;
|
||||
|
||||
double measuredDepth = wellPathSourceInfo->measuredDepth(uiEvent->firstPartTriangleIndex, unscaledIntersection + displayModelOffset);
|
||||
cvf::Vec3d trueVerticalDepth = wellPathSourceInfo->trueVerticalDepth(uiEvent->firstPartTriangleIndex, unscaledIntersection + displayModelOffset);
|
||||
double measuredDepth = wellPathSourceInfo->measuredDepth(uiEvent->firstPartTriangleIndex, domainCoord);
|
||||
cvf::Vec3d trueVerticalDepth = wellPathSourceInfo->trueVerticalDepth(uiEvent->firstPartTriangleIndex, domainCoord);
|
||||
|
||||
QString wellPathText;
|
||||
wellPathText += QString("Well path name : %1\n").arg(wellPathSourceInfo->wellPath()->name);
|
||||
|
||||
@@ -144,6 +144,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
|
||||
|
||||
uint firstPartTriangleIndex = cvf::UNDEFINED_UINT;
|
||||
cvf::Vec3d localIntersectionPoint(cvf::Vec3d::ZERO);
|
||||
cvf::Vec3d globalIntersectionPoint(cvf::Vec3d::ZERO);
|
||||
|
||||
cvf::Part* firstHitPart = NULL;
|
||||
cvf::Part* nncFirstHitPart = NULL;
|
||||
@@ -153,7 +154,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
|
||||
cvf::HitItemCollection hitItems;
|
||||
if (m_viewer->rayPick(winPosX, winPosY, &hitItems))
|
||||
{
|
||||
extractIntersectionData(hitItems, &localIntersectionPoint, &firstHitPart, &firstPartTriangleIndex, &nncFirstHitPart, NULL);
|
||||
extractIntersectionData(hitItems, &localIntersectionPoint, &globalIntersectionPoint, &firstHitPart, &firstPartTriangleIndex, &nncFirstHitPart, NULL);
|
||||
|
||||
cvf::Vec3d displayModelOffset = cvf::Vec3d::ZERO;
|
||||
|
||||
@@ -475,6 +476,7 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
|
||||
std::array<cvf::Vec3f, 3> intersectionTriangleHit;
|
||||
|
||||
cvf::Vec3d localIntersectionPoint(cvf::Vec3d::ZERO);
|
||||
cvf::Vec3d globalIntersectionPoint(cvf::Vec3d::ZERO);
|
||||
|
||||
// Extract all the above information from the pick
|
||||
{
|
||||
@@ -487,9 +489,9 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
|
||||
cvf::HitItemCollection hitItems;
|
||||
if (m_viewer->rayPick(winPosX, winPosY, &hitItems))
|
||||
{
|
||||
extractIntersectionData(hitItems, &localIntersectionPoint, &firstHitPart, &firstPartTriangleIndex, &firstNncHitPart, &nncPartTriangleIndex);
|
||||
extractIntersectionData(hitItems, &localIntersectionPoint, &globalIntersectionPoint, &firstHitPart, &firstPartTriangleIndex, &firstNncHitPart, &nncPartTriangleIndex);
|
||||
|
||||
cvf::ref<RicViewerEventObject> eventObj = new RicViewerEventObject(localIntersectionPoint, firstHitPart, firstPartTriangleIndex);
|
||||
cvf::ref<RicViewerEventObject> eventObj = new RicViewerEventObject(globalIntersectionPoint, firstHitPart, firstPartTriangleIndex);
|
||||
for (size_t i = 0; i < m_viewerEventHandlers.size(); i++)
|
||||
{
|
||||
if (m_viewerEventHandlers[i]->handleEvent(eventObj.p()))
|
||||
@@ -675,7 +677,9 @@ void RiuViewerCommands::findCellAndGridIndex(const RivIntersectionBoxSourceInfo*
|
||||
/// Perform picking and return the index of the face that was hit, if a drawable geo was hit
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewerCommands::extractIntersectionData(const cvf::HitItemCollection& hitItems,
|
||||
cvf::Vec3d* localIntersectionPoint, cvf::Part** firstPart, uint* firstPartFaceHit,
|
||||
cvf::Vec3d* localIntersectionPoint,
|
||||
cvf::Vec3d* globalIntersectionPoint,
|
||||
cvf::Part** firstPart, uint* firstPartFaceHit,
|
||||
cvf::Part** nncPart, uint* nncPartFaceHit)
|
||||
{
|
||||
CVF_ASSERT(hitItems.count() > 0);
|
||||
@@ -748,6 +752,11 @@ void RiuViewerCommands::extractIntersectionData(const cvf::HitItemCollection& hi
|
||||
const cvf::Transform* xf = pickedPart->transform();
|
||||
cvf::Vec3d globalPickedPoint = firstNonNncHitItem->intersectionPoint();
|
||||
|
||||
if (globalIntersectionPoint)
|
||||
{
|
||||
*globalIntersectionPoint = globalPickedPoint;
|
||||
}
|
||||
|
||||
if (localIntersectionPoint)
|
||||
{
|
||||
if (xf)
|
||||
@@ -775,6 +784,11 @@ void RiuViewerCommands::extractIntersectionData(const cvf::HitItemCollection& hi
|
||||
{
|
||||
cvf::Vec3d globalPickedPoint = firstItemIntersectionPoint;
|
||||
|
||||
if (globalIntersectionPoint)
|
||||
{
|
||||
*globalIntersectionPoint = globalPickedPoint;
|
||||
}
|
||||
|
||||
const cvf::Transform* xf = (*nncPart)->transform();
|
||||
if (xf)
|
||||
{
|
||||
|
||||
@@ -76,7 +76,7 @@ private:
|
||||
|
||||
void ijkFromCellIndex(size_t gridIdx, size_t cellIndex, size_t* i, size_t* j, size_t* k);
|
||||
void createSliceRangeFilter(int ijOrk);
|
||||
void extractIntersectionData(const cvf::HitItemCollection& hitItems, cvf::Vec3d* localIntersectionPoint, cvf::Part** firstPart, uint* firstPartFaceHit, cvf::Part** nncPart, uint* nncPartFaceHit);
|
||||
void extractIntersectionData(const cvf::HitItemCollection& hitItems, cvf::Vec3d* localIntersectionPoint, cvf::Vec3d* globalIntersectionPoint, cvf::Part** firstPart, uint* firstPartFaceHit, cvf::Part** nncPart, uint* nncPartFaceHit);
|
||||
|
||||
bool handleOverlayItemPicking(int winPosX, int winPosY);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user