mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-09 23:16:00 -06:00
IJK-Slice context menu commands for GeoMech
#306 Added picking source data to the viz model Generalized the picking methods in RiuViewer, but there is more serious refactoring needed.
This commit is contained in:
parent
ba633bd847
commit
0130a01ca2
@ -8,12 +8,15 @@ set (SOURCE_GROUP_HEADER_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RivFemPartGeometryGenerator.h
|
||||
${CEE_CURRENT_LIST_DIR}RivFemPartPartMgr.h
|
||||
${CEE_CURRENT_LIST_DIR}RivGeoMechPartMgr.h
|
||||
${CEE_CURRENT_LIST_DIR}RivFemPickSourceInfo.h
|
||||
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RivFemPartGeometryGenerator.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivFemPartPartMgr.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivGeoMechPartMgr.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RivFemPickSourceInfo.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
@ -30,7 +30,7 @@ RivFemPartGeometryGenerator::RivFemPartGeometryGenerator(const RigFemPart* part)
|
||||
: m_part(part)
|
||||
{
|
||||
CVF_ASSERT(part);
|
||||
|
||||
m_triangleMapper = new RivFemPartTriangleToElmMapper;
|
||||
}
|
||||
|
||||
|
||||
@ -153,16 +153,21 @@ ref<UIntArray> RivFemPartGeometryGenerator::lineIndicesFromQuadVertexArray(const
|
||||
void RivFemPartGeometryGenerator::computeArrays()
|
||||
{
|
||||
std::vector<Vec3f> vertices;
|
||||
std::vector<int>& trianglesToElements = m_triangleMapper->triangleToElmIndexMap();
|
||||
std::vector<char>& trianglesToElementFaces = m_triangleMapper->triangleToElmFaceMap();
|
||||
|
||||
m_quadVerticesToNodeIdx.clear();
|
||||
m_quadVerticesToGlobalElmNodeIdx.clear();
|
||||
trianglesToElements.clear();
|
||||
trianglesToElementFaces.clear();
|
||||
|
||||
size_t estimatedQuadVxCount = m_part->elementCount()*6*4;
|
||||
|
||||
vertices.reserve(estimatedQuadVxCount);
|
||||
m_quadVerticesToNodeIdx.reserve(estimatedQuadVxCount);
|
||||
m_quadVerticesToGlobalElmNodeIdx.reserve(estimatedQuadVxCount);
|
||||
|
||||
|
||||
trianglesToElements.reserve(estimatedQuadVxCount/2);
|
||||
trianglesToElementFaces.reserve(estimatedQuadVxCount/2);
|
||||
|
||||
cvf::Vec3d offset = Vec3d::ZERO; //m_part->displayModelOffset();
|
||||
const std::vector<cvf::Vec3f>& nodeCoordinates = m_part->nodes().coordinates;
|
||||
@ -229,6 +234,11 @@ void RivFemPartGeometryGenerator::computeArrays()
|
||||
m_quadVerticesToGlobalElmNodeIdx.push_back(qElmNodeResIdx[1]);
|
||||
m_quadVerticesToGlobalElmNodeIdx.push_back(qElmNodeResIdx[2]);
|
||||
m_quadVerticesToGlobalElmNodeIdx.push_back(qElmNodeResIdx[3]);
|
||||
|
||||
trianglesToElements.push_back(elmIdx);
|
||||
trianglesToElements.push_back(elmIdx);
|
||||
trianglesToElementFaces.push_back(lfIdx);
|
||||
trianglesToElementFaces.push_back(lfIdx);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "cvfArray.h"
|
||||
|
||||
#include "RigFemPart.h"
|
||||
#include "cvfStructGrid.h"
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
@ -16,7 +17,22 @@ class ScalarMapper;
|
||||
|
||||
class RigFemPartScalarDataAccess;
|
||||
|
||||
class RivFemPartTriangleToElmMapper : public cvf::Object
|
||||
{
|
||||
public:
|
||||
size_t triangleCount() const { return m_trianglesToElementIndex.size();}
|
||||
|
||||
int elementIndex(size_t triangleIdx) const { return m_trianglesToElementIndex[triangleIdx]; }
|
||||
char elementFace(size_t triangleIdx) const { return m_trianglesToElmFace[triangleIdx]; }
|
||||
|
||||
// Interface for building the mappings
|
||||
std::vector<int>& triangleToElmIndexMap() { return m_trianglesToElementIndex; }
|
||||
std::vector<char>& triangleToElmFaceMap() { return m_trianglesToElmFace; }
|
||||
|
||||
private:
|
||||
std::vector<int> m_trianglesToElementIndex;
|
||||
std::vector<char> m_trianglesToElmFace;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
@ -38,13 +54,16 @@ public:
|
||||
const RigFemPart* activePart() { return m_part.p(); }
|
||||
|
||||
// Generated geometry
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> generateSurface();
|
||||
cvf::ref<cvf::DrawableGeo> createMeshDrawable();
|
||||
cvf::ref<cvf::DrawableGeo> createOutlineMeshDrawable(double creaseAngle);
|
||||
|
||||
const std::vector<size_t>& quadVerticesToNodeIdxMapping() const { return m_quadVerticesToNodeIdx;}
|
||||
const std::vector<size_t>& quadVerticesToNodeIdxMapping() const { return m_quadVerticesToNodeIdx;}
|
||||
const std::vector<size_t>& quadVerticesToGlobalElmNodeIdx() const { return m_quadVerticesToGlobalElmNodeIdx;}
|
||||
|
||||
RivFemPartTriangleToElmMapper* triangleToElementMapper() { return m_triangleMapper.p();}
|
||||
|
||||
private:
|
||||
static cvf::ref<cvf::UIntArray>
|
||||
lineIndicesFromQuadVertexArray(const cvf::Vec3fArray* vertexArray);
|
||||
@ -53,13 +72,16 @@ private:
|
||||
private:
|
||||
// Input
|
||||
cvf::cref<RigFemPart> m_part; // The part being processed
|
||||
cvf::cref<cvf::UByteArray> m_elmVisibility;
|
||||
cvf::cref<cvf::UByteArray> m_elmVisibility;
|
||||
|
||||
// Created arrays
|
||||
cvf::ref<cvf::Vec3fArray> m_quadVertices;
|
||||
//cvf::ref<cvf::Vec3fArray> m_triangleVertices; // If needed, we will do it like this, I think
|
||||
std::vector<size_t> m_quadVerticesToNodeIdx;
|
||||
std::vector<size_t> m_quadVerticesToGlobalElmNodeIdx;
|
||||
//cvf::ref<cvf::Vec3fArray> m_triangleVertices; // If needed, we will do it like this, I think
|
||||
std::vector<size_t> m_quadVerticesToNodeIdx;
|
||||
std::vector<size_t> m_quadVerticesToGlobalElmNodeIdx;
|
||||
|
||||
// Mappings
|
||||
cvf::ref<RivFemPartTriangleToElmMapper> m_triangleMapper;
|
||||
|
||||
};
|
||||
|
||||
|
@ -51,6 +51,7 @@
|
||||
#include "RigGeoMechCaseData.h"
|
||||
#include "RigFemScalarResultFrames.h"
|
||||
#include "RigFemPartResultsCollection.h"
|
||||
#include "RivFemPickSourceInfo.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -110,15 +111,13 @@ void RivFemPartPartMgr::generatePartGeometry(RivFemPartGeometryGenerator& geoBui
|
||||
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
part->setName("FemPart " + cvf::String(m_gridIdx));
|
||||
part->setId(m_gridIdx); // !! For now, use grid index as part ID (needed for pick info)
|
||||
part->setId(m_gridIdx); // Use grid index as part ID
|
||||
part->setDrawable(geo.p());
|
||||
part->setTransform(m_scaleTransform.p());
|
||||
|
||||
// Set mapping from triangle face index to cell index
|
||||
//cvf::ref<RivSourceInfo> si = new RivSourceInfo;
|
||||
//si->m_cellFaceFromTriangleMapper = geoBuilder.triangleToCellFaceMapper();
|
||||
//
|
||||
//part->setSourceInfo(si.p());
|
||||
// Set mapping from triangle face index to element index
|
||||
cvf::ref<RivFemPickSourceInfo> si = new RivFemPickSourceInfo(m_gridIdx, geoBuilder.triangleToElementMapper());
|
||||
part->setSourceInfo(si.p());
|
||||
|
||||
part->updateBoundingBox();
|
||||
|
||||
|
@ -49,33 +49,33 @@ class RivFemPartPartMgr: public cvf::Object
|
||||
public:
|
||||
RivFemPartPartMgr(const RigFemPart* femPart);
|
||||
~RivFemPartPartMgr();
|
||||
void setTransform(cvf::Transform* scaleTransform);
|
||||
void setCellVisibility(cvf::UByteArray* cellVisibilities );
|
||||
cvf::ref<cvf::UByteArray> cellVisibility() { return m_cellVisibility;}
|
||||
|
||||
void updateCellColor(cvf::Color4f color);
|
||||
void updateCellResultColor(size_t timeStepIndex, RimGeoMechResultSlot* cellResultSlot);
|
||||
|
||||
void appendPartsToModel(cvf::ModelBasicList* model);
|
||||
void setTransform(cvf::Transform* scaleTransform);
|
||||
void setCellVisibility(cvf::UByteArray* cellVisibilities );
|
||||
cvf::ref<cvf::UByteArray> cellVisibility() { return m_cellVisibility;}
|
||||
|
||||
void updateCellColor(cvf::Color4f color);
|
||||
void updateCellResultColor(size_t timeStepIndex, RimGeoMechResultSlot* cellResultSlot);
|
||||
|
||||
void appendPartsToModel(cvf::ModelBasicList* model);
|
||||
|
||||
private:
|
||||
void generatePartGeometry(RivFemPartGeometryGenerator& geoBuilder);
|
||||
|
||||
private:
|
||||
void generatePartGeometry(RivFemPartGeometryGenerator& geoBuilder);
|
||||
int m_gridIdx;
|
||||
cvf::cref<RigFemPart> m_grid;
|
||||
|
||||
private:
|
||||
int m_gridIdx;
|
||||
cvf::cref<RigFemPart> m_grid;
|
||||
|
||||
cvf::ref<cvf::Transform> m_scaleTransform;
|
||||
float m_opacityLevel;
|
||||
cvf::Color3f m_defaultColor;
|
||||
cvf::ref<cvf::Transform> m_scaleTransform;
|
||||
float m_opacityLevel;
|
||||
cvf::Color3f m_defaultColor;
|
||||
|
||||
// Surface visualization
|
||||
RivFemPartGeometryGenerator m_surfaceGenerator;
|
||||
RivFemPartGeometryGenerator m_surfaceGenerator;
|
||||
|
||||
cvf::ref<cvf::Part> m_surfaceFaces;
|
||||
cvf::ref<cvf::Vec2fArray> m_surfaceFacesTextureCoords;
|
||||
cvf::ref<cvf::Part> m_surfaceFaces;
|
||||
cvf::ref<cvf::Vec2fArray> m_surfaceFacesTextureCoords;
|
||||
|
||||
cvf::ref<cvf::Part> m_surfaceGridLines;
|
||||
cvf::ref<cvf::Part> m_surfaceGridLines;
|
||||
|
||||
cvf::ref<cvf::UByteArray> m_cellVisibility;
|
||||
cvf::ref<cvf::UByteArray> m_cellVisibility;
|
||||
};
|
||||
|
@ -0,0 +1,41 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RivFemPickSourceInfo.h"
|
||||
|
||||
#include "RivFemPartGeometryGenerator.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivFemPickSourceInfo::RivFemPickSourceInfo(int partIndex, RivFemPartTriangleToElmMapper * triangleToElmMapper)
|
||||
: m_fempartIndex(partIndex),
|
||||
m_triangleToElmMapper(triangleToElmMapper)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivFemPickSourceInfo::~RivFemPickSourceInfo()
|
||||
{
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
|
||||
class RivFemPartTriangleToElmMapper;
|
||||
|
||||
|
||||
class RivFemPickSourceInfo : public cvf::Object
|
||||
{
|
||||
public:
|
||||
RivFemPickSourceInfo(int partIndex, RivFemPartTriangleToElmMapper * triangleToElmMapper);
|
||||
~RivFemPickSourceInfo();
|
||||
|
||||
int femPartIndex() const { return m_fempartIndex; }
|
||||
const RivFemPartTriangleToElmMapper* triangleToElmMapper() const { return m_triangleToElmMapper.p(); }
|
||||
|
||||
private:
|
||||
int m_fempartIndex;
|
||||
cvf::cref<RivFemPartTriangleToElmMapper> m_triangleToElmMapper;
|
||||
};
|
||||
|
||||
|
@ -50,7 +50,16 @@
|
||||
#include "cafPdmFieldCvfColor.h"
|
||||
#include "cafPdmFieldCvfMat4d.h"
|
||||
#include "RivSourceInfo.h"
|
||||
#include "RivFemPickSourceInfo.h"
|
||||
|
||||
#include "RiuResultTextBuilder.h"
|
||||
#include "RivFemPartGeometryGenerator.h"
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimGeoMechCase.h"
|
||||
#include "RigGeomechCaseData.h"
|
||||
#include "RigFemPartCollection.h"
|
||||
#include "RigFemPart.h"
|
||||
#include "RigFemPartGrid.h"
|
||||
|
||||
using cvf::ManipulatorTrackball;
|
||||
|
||||
@ -192,11 +201,8 @@ void RiuViewer::setDefaultView()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewer::mouseReleaseEvent(QMouseEvent* event)
|
||||
{
|
||||
m_mouseState.updateFromMouseEvent(event);
|
||||
|
||||
if (!this->canRender()) return;
|
||||
|
||||
// Picking
|
||||
if (event->button() == Qt::LeftButton)
|
||||
{
|
||||
handlePickAction(event->x(), event->y());
|
||||
@ -204,12 +210,6 @@ void RiuViewer::mouseReleaseEvent(QMouseEvent* event)
|
||||
}
|
||||
else if (event->button() == Qt::RightButton)
|
||||
{
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
|
||||
if (!eclipseView) return;
|
||||
|
||||
m_currentGridIdx = cvf::UNDEFINED_SIZE_T;
|
||||
m_currentCellIndex = cvf::UNDEFINED_SIZE_T;
|
||||
|
||||
QPoint diffPoint = event->pos() - m_lastMousePressPosition;
|
||||
if (diffPoint.manhattanLength() > 3)
|
||||
{
|
||||
@ -217,55 +217,82 @@ void RiuViewer::mouseReleaseEvent(QMouseEvent* event)
|
||||
return;
|
||||
}
|
||||
|
||||
int winPosX = event->x();
|
||||
int winPosY = event->y();
|
||||
|
||||
uint faceIndex = cvf::UNDEFINED_UINT;
|
||||
cvf::Vec3d localIntersectionPoint(cvf::Vec3d::ZERO);
|
||||
|
||||
cvf::Part* firstHitPart = NULL;
|
||||
cvf::Part* nncFirstHitPart = NULL;
|
||||
pickPointAndFace(winPosX, winPosY, &localIntersectionPoint, &firstHitPart, &faceIndex, &nncFirstHitPart, NULL);
|
||||
if (firstHitPart)
|
||||
{
|
||||
if (faceIndex != cvf::UNDEFINED_UINT)
|
||||
{
|
||||
if (firstHitPart->sourceInfo())
|
||||
{
|
||||
const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>(firstHitPart->sourceInfo());
|
||||
if (rivSourceInfo)
|
||||
{
|
||||
if (rivSourceInfo->hasCellFaceMapping())
|
||||
{
|
||||
m_currentGridIdx = firstHitPart->id();
|
||||
m_currentCellIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellIndex(faceIndex);
|
||||
m_currentFaceIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellFace(faceIndex);
|
||||
|
||||
QMenu menu;
|
||||
|
||||
menu.addAction(QString("I-slice range filter"), this, SLOT(slotRangeFilterI()));
|
||||
menu.addAction(QString("J-slice range filter"), this, SLOT(slotRangeFilterJ()));
|
||||
menu.addAction(QString("K-slice range filter"), this, SLOT(slotRangeFilterK()));
|
||||
|
||||
const RigCaseData* reservoir = eclipseView->eclipseCase()->reservoirData();
|
||||
const RigFault* fault = reservoir->mainGrid()->findFaultFromCellIndexAndCellFace(m_currentCellIndex, m_currentFaceIndex);
|
||||
if (fault)
|
||||
{
|
||||
menu.addSeparator();
|
||||
|
||||
QString faultName = fault->name();
|
||||
menu.addAction(QString("Hide ") + faultName, this, SLOT(slotHideFault()));
|
||||
}
|
||||
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
displayContextMenu(event);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewer::displayContextMenu(QMouseEvent* event)
|
||||
{
|
||||
m_currentGridIdx = cvf::UNDEFINED_SIZE_T;
|
||||
m_currentCellIndex = cvf::UNDEFINED_SIZE_T;
|
||||
|
||||
int winPosX = event->x();
|
||||
int winPosY = event->y();
|
||||
|
||||
uint faceIndex = cvf::UNDEFINED_UINT;
|
||||
cvf::Vec3d localIntersectionPoint(cvf::Vec3d::ZERO);
|
||||
|
||||
cvf::Part* firstHitPart = NULL;
|
||||
cvf::Part* nncFirstHitPart = NULL;
|
||||
|
||||
findPointAndFaceFromMousePos(winPosX, winPosY, &localIntersectionPoint, &firstHitPart, &faceIndex, &nncFirstHitPart, NULL);
|
||||
|
||||
if (!firstHitPart) return;
|
||||
|
||||
if (faceIndex == cvf::UNDEFINED_UINT) return;
|
||||
|
||||
if (!firstHitPart->sourceInfo()) return;
|
||||
|
||||
const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>(firstHitPart->sourceInfo());
|
||||
const RivFemPickSourceInfo* femSourceInfo = dynamic_cast<const RivFemPickSourceInfo*>(firstHitPart->sourceInfo());
|
||||
|
||||
if (!(rivSourceInfo || femSourceInfo) ) return;
|
||||
|
||||
if (rivSourceInfo)
|
||||
{
|
||||
if (!rivSourceInfo->hasCellFaceMapping()) return;
|
||||
|
||||
// Set the data regarding what was hit
|
||||
|
||||
m_currentGridIdx = firstHitPart->id();
|
||||
m_currentCellIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellIndex(faceIndex);
|
||||
m_currentFaceIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellFace(faceIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_currentGridIdx = femSourceInfo->femPartIndex();
|
||||
m_currentCellIndex = femSourceInfo->triangleToElmMapper()->elementIndex(faceIndex);
|
||||
}
|
||||
|
||||
// IJK -slice commands
|
||||
|
||||
QMenu menu;
|
||||
|
||||
menu.addAction(QString("I-slice range filter"), this, SLOT(slotRangeFilterI()));
|
||||
menu.addAction(QString("J-slice range filter"), this, SLOT(slotRangeFilterJ()));
|
||||
menu.addAction(QString("K-slice range filter"), this, SLOT(slotRangeFilterK()));
|
||||
|
||||
// Hide faults command
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
|
||||
if (eclipseView)
|
||||
{
|
||||
const RigCaseData* reservoir = eclipseView->eclipseCase()->reservoirData();
|
||||
const RigFault* fault = reservoir->mainGrid()->findFaultFromCellIndexAndCellFace(m_currentCellIndex, m_currentFaceIndex);
|
||||
if (fault)
|
||||
{
|
||||
menu.addSeparator();
|
||||
|
||||
QString faultName = fault->name();
|
||||
menu.addAction(QString("Hide ") + faultName, this, SLOT(slotHideFault()));
|
||||
}
|
||||
}
|
||||
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Todo: Move this to a command instead
|
||||
@ -293,7 +320,7 @@ void RiuViewer::slotRangeFilterK()
|
||||
|
||||
void RiuViewer::createSliceRangeFilter(int ijOrk)
|
||||
{
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
|
||||
RimView* eclipseView = m_reservoirView.p();
|
||||
if (!eclipseView) return;
|
||||
|
||||
size_t i, j, k;
|
||||
@ -379,7 +406,7 @@ void RiuViewer::handlePickAction(int winPosX, int winPosY)
|
||||
cvf::Part* firstNncHitPart = NULL;
|
||||
uint nncPartFaceIndex = cvf::UNDEFINED_UINT;
|
||||
|
||||
pickPointAndFace(winPosX, winPosY, &localIntersectionPoint, &firstHitPart, &firstPartFaceIndex, &firstNncHitPart, &nncPartFaceIndex);
|
||||
findPointAndFaceFromMousePos(winPosX, winPosY, &localIntersectionPoint, &firstHitPart, &firstPartFaceIndex, &firstNncHitPart, &nncPartFaceIndex);
|
||||
|
||||
if (firstHitPart)
|
||||
{
|
||||
@ -497,10 +524,10 @@ void RiuViewer::setEnableMask(unsigned int mask)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Perform picking and return the index of the face that was hit, if a drawable geo was hit
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewer::pickPointAndFace(int winPosX, int winPosY, cvf::Vec3d* localIntersectionPoint, cvf::Part** firstPart, uint* firstPartFaceHit, cvf::Part** nncPart, uint* nncPartFaceHit)
|
||||
void RiuViewer::findPointAndFaceFromMousePos(int winPosX, int winPosY,
|
||||
cvf::Vec3d* localIntersectionPoint, cvf::Part** firstPart, uint* firstPartFaceHit,
|
||||
cvf::Part** nncPart, uint* nncPartFaceHit)
|
||||
{
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
|
||||
if(!eclipseView) return;
|
||||
|
||||
cvf::HitItemCollection hitItems;
|
||||
bool isSomethingHit = rayPick(winPosX, winPosY, &hitItems);
|
||||
@ -509,19 +536,23 @@ void RiuViewer::pickPointAndFace(int winPosX, int winPosY, cvf::Vec3d* localInte
|
||||
{
|
||||
CVF_ASSERT(hitItems.count() > 0);
|
||||
|
||||
double characteristicCellSize = 5.0;
|
||||
if (eclipseView && eclipseView->eclipseCase())
|
||||
double pickDepthThresholdSquared = 0.05 *0.05;
|
||||
{
|
||||
characteristicCellSize = eclipseView->eclipseCase()->reservoirData()->mainGrid()->characteristicIJCellSize();
|
||||
}
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
|
||||
|
||||
double pickDepthThresholdSquared = characteristicCellSize / 100.0;
|
||||
pickDepthThresholdSquared = pickDepthThresholdSquared * pickDepthThresholdSquared;
|
||||
if (eclipseView && eclipseView->eclipseCase())
|
||||
{
|
||||
double characteristicCellSize = eclipseView->eclipseCase()->reservoirData()->mainGrid()->characteristicIJCellSize();
|
||||
pickDepthThresholdSquared = characteristicCellSize / 100.0;
|
||||
pickDepthThresholdSquared = pickDepthThresholdSquared * pickDepthThresholdSquared;
|
||||
}
|
||||
}
|
||||
|
||||
cvf::HitItem* firstNonNncHitItem = NULL;
|
||||
cvf::Vec3d firstItemIntersectionPoint = hitItems.item(0)->intersectionPoint();
|
||||
|
||||
// Check if we have a close hit item with NNC data
|
||||
|
||||
for (size_t i = 0; i < hitItems.count(); i++)
|
||||
{
|
||||
cvf::HitItem* hitItemCandidate = hitItems.item(i);
|
||||
@ -529,13 +560,15 @@ void RiuViewer::pickPointAndFace(int winPosX, int winPosY, cvf::Vec3d* localInte
|
||||
|
||||
const cvf::Part* pickedPartCandidate = hitItemCandidate->part();
|
||||
bool isNncpart = false;
|
||||
|
||||
if (pickedPartCandidate && pickedPartCandidate->sourceInfo())
|
||||
{
|
||||
// Hit items are ordered by distance from eye
|
||||
if (diff.lengthSquared() < pickDepthThresholdSquared)
|
||||
const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>(pickedPartCandidate->sourceInfo());
|
||||
if (rivSourceInfo && rivSourceInfo->hasNNCIndices())
|
||||
{
|
||||
const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>(pickedPartCandidate->sourceInfo());
|
||||
if (rivSourceInfo && rivSourceInfo->hasNNCIndices())
|
||||
|
||||
// Hit items are ordered by distance from eye
|
||||
if (diff.lengthSquared() < pickDepthThresholdSquared)
|
||||
{
|
||||
*nncPart = const_cast<cvf::Part*>(pickedPartCandidate);
|
||||
|
||||
@ -697,13 +730,18 @@ void RiuViewer::showHistogram(bool enable)
|
||||
void RiuViewer::ijkFromCellIndex(size_t gridIdx, size_t cellIndex, size_t* i, size_t* j, size_t* k)
|
||||
{
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
|
||||
if(!eclipseView) return;
|
||||
RimGeoMechView* geomView = dynamic_cast<RimGeoMechView*>(m_reservoirView.p());
|
||||
|
||||
|
||||
if (eclipseView->eclipseCase())
|
||||
if (eclipseView && eclipseView->eclipseCase())
|
||||
{
|
||||
eclipseView->eclipseCase()->reservoirData()->grid(gridIdx)->ijkFromCellIndex(cellIndex, i, j, k);
|
||||
}
|
||||
|
||||
if (geomView && geomView->geoMechCase())
|
||||
{
|
||||
geomView->geoMechCase()->geoMechData()->femParts()->part(gridIdx)->structGrid()->ijkFromCellIndex(cellIndex, i, j, k);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -79,10 +79,13 @@ protected:
|
||||
void paintOverlayItems(QPainter* painter);
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
void mouseReleaseEvent(QMouseEvent* event);
|
||||
|
||||
void displayContextMenu(QMouseEvent* event);
|
||||
|
||||
void mousePressEvent(QMouseEvent* event);
|
||||
|
||||
void handlePickAction(int winPosX, int winPosY);
|
||||
void pickPointAndFace(int winPosX, int winPosY, cvf::Vec3d* localIntersectionPoint, cvf::Part** firstPart, uint* firstPartFaceHit, cvf::Part** nncPart, uint* nncPartFaceHit);
|
||||
void findPointAndFaceFromMousePos(int winPosX, int winPosY, cvf::Vec3d* localIntersectionPoint, cvf::Part** firstPart, uint* firstPartFaceHit, cvf::Part** nncPart, uint* nncPartFaceHit);
|
||||
|
||||
private slots:
|
||||
void slotRangeFilterI();
|
||||
@ -93,8 +96,6 @@ private slots:
|
||||
private:
|
||||
void ijkFromCellIndex(size_t gridIdx, size_t cellIndex, size_t* i, size_t* j, size_t* k);
|
||||
void createSliceRangeFilter(int ijOrk);
|
||||
private:
|
||||
caf::QtMouseState m_mouseState;
|
||||
|
||||
QLabel* m_InfoLabel;
|
||||
bool m_showInfoText;;
|
||||
|
Loading…
Reference in New Issue
Block a user