mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#678) Show context menu commands on intersection
Added hide intersection
This commit is contained in:
@@ -18,21 +18,26 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RivCrossSectionGeometryGenerator.h"
|
||||
#include "cvfBoundingBox.h"
|
||||
|
||||
#include "RigMainGrid.h"
|
||||
#include "cvfDrawableGeo.h"
|
||||
#include "RigResultAccessor.h"
|
||||
#include "cvfScalarMapper.h"
|
||||
|
||||
#include "RimCrossSection.h"
|
||||
|
||||
#include "cvfDrawableGeo.h"
|
||||
#include "cvfPrimitiveSetDirect.h"
|
||||
#include "cvfScalarMapper.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivCrossSectionGeometryGenerator::RivCrossSectionGeometryGenerator(const std::vector<std::vector<cvf::Vec3d> > &polylines,
|
||||
const cvf::Vec3d& extrusionDirection,
|
||||
const RivCrossSectionHexGridIntf* grid)
|
||||
: m_polyLines(polylines),
|
||||
RivCrossSectionGeometryGenerator::RivCrossSectionGeometryGenerator(const RimCrossSection* crossSection,
|
||||
std::vector<std::vector<cvf::Vec3d> > &polylines,
|
||||
const cvf::Vec3d& extrusionDirection,
|
||||
const RivCrossSectionHexGridIntf* grid)
|
||||
: m_crossSection(crossSection),
|
||||
m_polyLines(polylines),
|
||||
m_extrusionDirection(extrusionDirection),
|
||||
m_hexGrid(grid)
|
||||
{
|
||||
@@ -1185,6 +1190,13 @@ const std::vector<RivVertexWeights>& RivCrossSectionGeometryGenerator::triangleV
|
||||
return m_triVxToCellCornerWeights;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const RimCrossSection* RivCrossSectionGeometryGenerator::crossSection() const
|
||||
{
|
||||
return m_crossSection;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
|
||||
@@ -18,15 +18,20 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
#include "cvfArray.h"
|
||||
#include "cvfBase.h"
|
||||
#include "cvfBoundingBox.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cvfVector3.h"
|
||||
#include "cvfArray.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RigMainGrid;
|
||||
class RigResultAccessor;
|
||||
class RimCrossSection;
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
@@ -34,7 +39,6 @@ namespace cvf
|
||||
class DrawableGeo;
|
||||
}
|
||||
|
||||
#include "cvfBoundingBox.h"
|
||||
|
||||
|
||||
class RivCrossSectionHexGridIntf : public cvf::Object
|
||||
@@ -124,7 +128,8 @@ private:
|
||||
class RivCrossSectionGeometryGenerator : public cvf::Object
|
||||
{
|
||||
public:
|
||||
RivCrossSectionGeometryGenerator(const std::vector<std::vector<cvf::Vec3d> > &polylines,
|
||||
RivCrossSectionGeometryGenerator(const RimCrossSection* crossSection,
|
||||
std::vector<std::vector<cvf::Vec3d> > &polylines,
|
||||
const cvf::Vec3d& extrusionDirection,
|
||||
const RivCrossSectionHexGridIntf* grid );
|
||||
|
||||
@@ -138,6 +143,8 @@ public:
|
||||
const std::vector<size_t>& triangleToCellIndex() const;
|
||||
const std::vector<RivVertexWeights>& triangleVxToCellCornerInterpolationWeights() const;
|
||||
|
||||
const RimCrossSection* crossSection() const;
|
||||
|
||||
private:
|
||||
void calculateArrays();
|
||||
static void adjustPolyline(const std::vector<cvf::Vec3d>& polyLine,
|
||||
@@ -153,5 +160,7 @@ private:
|
||||
cvf::ref<cvf::Vec3fArray> m_cellBorderLineVxes;
|
||||
std::vector<size_t> m_triangleToCellIdxMap;
|
||||
std::vector<RivVertexWeights> m_triVxToCellCornerWeights;
|
||||
|
||||
const RimCrossSection* m_crossSection;
|
||||
};
|
||||
|
||||
|
||||
@@ -417,7 +417,7 @@ void RivCrossSectionPartMgr::computeData()
|
||||
{
|
||||
cvf::Vec3d direction = extrusionDirection(polyLines[0]);
|
||||
cvf::ref<RivCrossSectionHexGridIntf> hexGrid = createHexGridInterface();
|
||||
m_crossSectionGenerator = new RivCrossSectionGeometryGenerator(polyLines, direction, hexGrid.p());
|
||||
m_crossSectionGenerator = new RivCrossSectionGeometryGenerator(m_rimCrossSection, polyLines, direction, hexGrid.p());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,3 +40,11 @@ const std::vector<size_t>& RivCrossSectionSourceInfo::triangleToCellIndex() cons
|
||||
|
||||
return m_crossSectionGeometryGenerator->triangleToCellIndex();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const RimCrossSection* RivCrossSectionSourceInfo::crossSection() const
|
||||
{
|
||||
return m_crossSectionGeometryGenerator->crossSection();
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "cvfArray.h"
|
||||
|
||||
class RivCrossSectionGeometryGenerator;
|
||||
class RimCrossSection;
|
||||
|
||||
class RivCrossSectionSourceInfo : public cvf::Object
|
||||
{
|
||||
@@ -32,6 +33,8 @@ public:
|
||||
|
||||
const std::vector<size_t>& triangleToCellIndex() const;
|
||||
|
||||
const RimCrossSection* crossSection() const;
|
||||
|
||||
private:
|
||||
cvf::cref<RivCrossSectionGeometryGenerator> m_crossSectionGeometryGenerator;
|
||||
};
|
||||
|
||||
@@ -408,6 +408,8 @@ const RigFault* RigMainGrid::findFaultFromCellIndexAndCellFace(size_t reservoirC
|
||||
{
|
||||
CVF_ASSERT(m_faultsPrCellAcc.notNull());
|
||||
|
||||
if (face == cvf::StructGridInterface::NO_FACE) return NULL;
|
||||
|
||||
int faultIdx = m_faultsPrCellAcc->faultIdx(reservoirCellIndex, face);
|
||||
if (faultIdx != RigFaultsPrCellAccumulator::NO_FAULT )
|
||||
{
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "RimCellRangeFilter.h"
|
||||
#include "RimCellRangeFilterCollection.h"
|
||||
#include "RimContextCommandBuilder.h"
|
||||
#include "RimCrossSection.h"
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseCellColors.h"
|
||||
#include "RimEclipsePropertyFilter.h"
|
||||
@@ -125,7 +126,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
|
||||
|
||||
QMenu menu;
|
||||
|
||||
uint faceIndex = cvf::UNDEFINED_UINT;
|
||||
uint firstPartTriangleIndex = cvf::UNDEFINED_UINT;
|
||||
cvf::Vec3d localIntersectionPoint(cvf::Vec3d::ZERO);
|
||||
|
||||
cvf::Part* firstHitPart = NULL;
|
||||
@@ -135,15 +136,16 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
|
||||
|
||||
if (m_viewer->rayPick(winPosX, winPosY, &hitItems))
|
||||
{
|
||||
extractIntersectionData(hitItems, &localIntersectionPoint, &firstHitPart, &faceIndex, &nncFirstHitPart, NULL);
|
||||
extractIntersectionData(hitItems, &localIntersectionPoint, &firstHitPart, &firstPartTriangleIndex, &nncFirstHitPart, NULL);
|
||||
}
|
||||
|
||||
if (firstHitPart && faceIndex != cvf::UNDEFINED_UINT)
|
||||
if (firstHitPart && firstPartTriangleIndex != cvf::UNDEFINED_UINT)
|
||||
{
|
||||
const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>(firstHitPart->sourceInfo());
|
||||
const RivFemPickSourceInfo* femSourceInfo = dynamic_cast<const RivFemPickSourceInfo*>(firstHitPart->sourceInfo());
|
||||
const RivCrossSectionSourceInfo* crossSectionSourceInfo = dynamic_cast<const RivCrossSectionSourceInfo*>(firstHitPart->sourceInfo());
|
||||
|
||||
if (rivSourceInfo || femSourceInfo)
|
||||
if (rivSourceInfo || femSourceInfo || crossSectionSourceInfo)
|
||||
{
|
||||
if (rivSourceInfo)
|
||||
{
|
||||
@@ -152,13 +154,21 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
|
||||
// Set the data regarding what was hit
|
||||
|
||||
m_currentGridIdx = rivSourceInfo->gridIndex();
|
||||
m_currentCellIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellIndex(faceIndex);
|
||||
m_currentFaceIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellFace(faceIndex);
|
||||
m_currentCellIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellIndex(firstPartTriangleIndex);
|
||||
m_currentFaceIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellFace(firstPartTriangleIndex);
|
||||
}
|
||||
else
|
||||
else if (femSourceInfo)
|
||||
{
|
||||
m_currentGridIdx = femSourceInfo->femPartIndex();
|
||||
m_currentCellIndex = femSourceInfo->triangleToElmMapper()->elementIndex(faceIndex);
|
||||
m_currentCellIndex = femSourceInfo->triangleToElmMapper()->elementIndex(firstPartTriangleIndex);
|
||||
}
|
||||
else if (crossSectionSourceInfo)
|
||||
{
|
||||
findCellAndGridIndex(crossSectionSourceInfo, firstPartTriangleIndex, &m_currentCellIndex, &m_currentGridIdx);
|
||||
m_currentFaceIndex = cvf::StructGridInterface::NO_FACE;
|
||||
m_currentCrossSection = const_cast<RimCrossSection*>(crossSectionSourceInfo->crossSection());
|
||||
|
||||
menu.addAction(QString("Hide intersection"), this, SLOT(slotHideIntersection()));
|
||||
}
|
||||
|
||||
// IJK -slice commands
|
||||
@@ -337,7 +347,6 @@ void RiuViewerCommands::slotHideFault()
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
|
||||
if(!eclipseView) return;
|
||||
|
||||
|
||||
const RigCaseData* reservoir = eclipseView->eclipseCase()->reservoirData();
|
||||
const RigFault* fault = reservoir->mainGrid()->findFaultFromCellIndexAndCellFace(m_currentCellIndex, m_currentFaceIndex);
|
||||
if (fault)
|
||||
@@ -384,6 +393,23 @@ void RiuViewerCommands::slotAddGeoMechPropertyFilter()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewerCommands::slotHideIntersection()
|
||||
{
|
||||
if (m_currentCrossSection)
|
||||
{
|
||||
m_currentCrossSection->isActive = false;
|
||||
m_currentCrossSection->updateConnectedEditors();
|
||||
|
||||
if (m_reservoirView)
|
||||
{
|
||||
m_reservoirView->scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -441,22 +467,7 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
|
||||
}
|
||||
else if (crossSectionSourceInfo)
|
||||
{
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
|
||||
RimGeoMechView* geomView = dynamic_cast<RimGeoMechView*>(m_reservoirView.p());
|
||||
|
||||
if (eclipseView)
|
||||
{
|
||||
size_t globalCellIndex = crossSectionSourceInfo->triangleToCellIndex()[firstPartTriangleIndex];
|
||||
|
||||
const RigCell& cell = eclipseView->eclipseCase()->reservoirData()->mainGrid()->globalCellArray()[globalCellIndex];
|
||||
cellIndex = cell.gridLocalCellIndex();
|
||||
gridIndex = cell.hostGrid()->gridIndex();
|
||||
}
|
||||
else if (geomView)
|
||||
{
|
||||
cellIndex = crossSectionSourceInfo->triangleToCellIndex()[firstPartTriangleIndex];
|
||||
gridIndex = 0;
|
||||
}
|
||||
findCellAndGridIndex(crossSectionSourceInfo, firstPartTriangleIndex, &cellIndex, &gridIndex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -525,6 +536,30 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewerCommands::findCellAndGridIndex(const RivCrossSectionSourceInfo* crossSectionSourceInfo, cvf::uint firstPartTriangleIndex, size_t* cellIndex, size_t* gridIndex)
|
||||
{
|
||||
CVF_ASSERT(cellIndex && gridIndex);
|
||||
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
|
||||
RimGeoMechView* geomView = dynamic_cast<RimGeoMechView*>(m_reservoirView.p());
|
||||
if (eclipseView)
|
||||
{
|
||||
size_t globalCellIndex = crossSectionSourceInfo->triangleToCellIndex()[firstPartTriangleIndex];
|
||||
|
||||
const RigCell& cell = eclipseView->eclipseCase()->reservoirData()->mainGrid()->globalCellArray()[globalCellIndex];
|
||||
*cellIndex = cell.gridLocalCellIndex();
|
||||
*gridIndex = cell.hostGrid()->gridIndex();
|
||||
}
|
||||
else if (geomView)
|
||||
{
|
||||
*cellIndex = crossSectionSourceInfo->triangleToCellIndex()[firstPartTriangleIndex];
|
||||
*gridIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Perform picking and return the index of the face that was hit, if a drawable geo was hit
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -18,19 +18,22 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
#include <QObject>
|
||||
|
||||
class RiuViewer;
|
||||
class RimView;
|
||||
class RimEclipseView;
|
||||
class RimGeoMechView;
|
||||
|
||||
class QMouseEvent;
|
||||
|
||||
#include "cvfStructGrid.h"
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QPointer>
|
||||
|
||||
class RimCrossSection;
|
||||
class RimEclipseView;
|
||||
class RimGeoMechView;
|
||||
class RimView;
|
||||
class RiuViewer;
|
||||
class RivCrossSectionSourceInfo;
|
||||
|
||||
class QMouseEvent;
|
||||
|
||||
namespace cvf {
|
||||
class HitItemCollection;
|
||||
class Part;
|
||||
@@ -49,6 +52,8 @@ public:
|
||||
void displayContextMenu(QMouseEvent* event);
|
||||
void handlePickAction(int winPosX, int winPosY, Qt::KeyboardModifiers keyboardModifiers);
|
||||
|
||||
void findCellAndGridIndex(const RivCrossSectionSourceInfo* crossSectionSourceInfo, cvf::uint firstPartTriangleIndex, size_t* cellIndex, size_t* gridIndex);
|
||||
|
||||
|
||||
private slots:
|
||||
void slotRangeFilterI();
|
||||
@@ -57,6 +62,7 @@ private slots:
|
||||
void slotHideFault();
|
||||
void slotAddEclipsePropertyFilter();
|
||||
void slotAddGeoMechPropertyFilter();
|
||||
void slotHideIntersection();
|
||||
|
||||
private:
|
||||
void ijkFromCellIndex(size_t gridIdx, size_t cellIndex, size_t* i, size_t* j, size_t* k);
|
||||
@@ -69,6 +75,7 @@ private:
|
||||
cvf::StructGridInterface::FaceType m_currentFaceIndex;
|
||||
|
||||
caf::PdmPointer<RimView> m_reservoirView;
|
||||
caf::PdmPointer<RimCrossSection> m_currentCrossSection;
|
||||
|
||||
QPointer<RiuViewer> m_viewer;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user