mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4857 Viewer Commands: Handle general picking in the comparison view
This commit is contained in:
@@ -163,7 +163,8 @@ public:
|
||||
void updateZScaleLabel();
|
||||
void updateMeasurement();
|
||||
|
||||
bool isMasterView() const;
|
||||
bool isMasterView() const;
|
||||
Rim3dView* activeComparisonView() const;
|
||||
|
||||
cvf::ref<caf::DisplayCoordTransform> displayCoordTransform() const override;
|
||||
|
||||
@@ -297,7 +298,6 @@ private:
|
||||
// Pure private methods : Override viewer and comparison view
|
||||
|
||||
void setOverrideViewer( RiuViewer* overrideViewer );
|
||||
Rim3dView* activeComparisonView() const;
|
||||
std::set<Rim3dView*> viewsUsingThisAsComparisonView();
|
||||
|
||||
Rim3dView* prepareComparisonView();
|
||||
|
||||
@@ -165,6 +165,10 @@ void RiuViewerCommands::displayContextMenu( QMouseEvent* event )
|
||||
}
|
||||
}
|
||||
|
||||
bool isComparisonViewPick = m_viewer->isMousePosWithinComparisonView( event->x(), event->y() );
|
||||
Rim3dView* mainOrComparisonView = isComparisonViewPick ? m_reservoirView->activeComparisonView()
|
||||
: m_reservoirView.p();
|
||||
|
||||
// Find the following data
|
||||
|
||||
const cvf::Part* firstHitPart = nullptr;
|
||||
@@ -202,9 +206,9 @@ void RiuViewerCommands::displayContextMenu( QMouseEvent* event )
|
||||
|
||||
cvf::Vec3d displayModelOffset = cvf::Vec3d::ZERO;
|
||||
|
||||
if ( m_reservoirView.p() )
|
||||
if ( mainOrComparisonView )
|
||||
{
|
||||
cvf::ref<caf::DisplayCoordTransform> transForm = m_reservoirView.p()->displayCoordTransform();
|
||||
cvf::ref<caf::DisplayCoordTransform> transForm = mainOrComparisonView->displayCoordTransform();
|
||||
m_currentPickPositionInDomainCoords = transForm->transformToDomainCoord( globalIntersectionPoint );
|
||||
}
|
||||
}
|
||||
@@ -218,8 +222,8 @@ void RiuViewerCommands::displayContextMenu( QMouseEvent* event )
|
||||
|
||||
// Check type of view
|
||||
|
||||
RimGridView* gridView = dynamic_cast<RimGridView*>( m_reservoirView.p() );
|
||||
Rim2dIntersectionView* int2dView = dynamic_cast<Rim2dIntersectionView*>( m_reservoirView.p() );
|
||||
RimGridView* gridView = dynamic_cast<RimGridView*>( mainOrComparisonView );
|
||||
Rim2dIntersectionView* int2dView = dynamic_cast<Rim2dIntersectionView*>( mainOrComparisonView );
|
||||
|
||||
if ( firstHitPart && firstPartTriangleIndex != cvf::UNDEFINED_UINT )
|
||||
{
|
||||
@@ -250,7 +254,8 @@ void RiuViewerCommands::displayContextMenu( QMouseEvent* event )
|
||||
}
|
||||
else if ( crossSectionSourceInfo )
|
||||
{
|
||||
findCellAndGridIndex( crossSectionSourceInfo,
|
||||
findCellAndGridIndex( mainOrComparisonView,
|
||||
crossSectionSourceInfo,
|
||||
firstPartTriangleIndex,
|
||||
&m_currentCellIndex,
|
||||
&m_currentGridIdx );
|
||||
@@ -273,7 +278,8 @@ void RiuViewerCommands::displayContextMenu( QMouseEvent* event )
|
||||
}
|
||||
else if ( intersectionBoxSourceInfo )
|
||||
{
|
||||
findCellAndGridIndex( intersectionBoxSourceInfo,
|
||||
findCellAndGridIndex( mainOrComparisonView,
|
||||
intersectionBoxSourceInfo,
|
||||
firstPartTriangleIndex,
|
||||
&m_currentCellIndex,
|
||||
&m_currentGridIdx );
|
||||
@@ -290,12 +296,12 @@ void RiuViewerCommands::displayContextMenu( QMouseEvent* event )
|
||||
{
|
||||
// IJK -slice commands
|
||||
RimViewController* viewController = nullptr;
|
||||
if ( m_reservoirView ) viewController = m_reservoirView->viewController();
|
||||
if ( mainOrComparisonView ) viewController = mainOrComparisonView->viewController();
|
||||
|
||||
if ( !viewController || !viewController->isRangeFiltersControlled() )
|
||||
{
|
||||
size_t i, j, k;
|
||||
ijkFromCellIndex( m_currentGridIdx, m_currentCellIndex, &i, &j, &k );
|
||||
ijkFromCellIndex( mainOrComparisonView, m_currentGridIdx, m_currentCellIndex, &i, &j, &k );
|
||||
|
||||
QVariantList iSliceList;
|
||||
iSliceList.push_back( 0 );
|
||||
@@ -347,7 +353,7 @@ void RiuViewerCommands::displayContextMenu( QMouseEvent* event )
|
||||
|
||||
menuBuilder.addSeparator();
|
||||
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( m_reservoirView.p() );
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( mainOrComparisonView );
|
||||
if ( eclipseView )
|
||||
{
|
||||
// Hide faults command
|
||||
@@ -582,11 +588,15 @@ void RiuViewerCommands::handlePickAction( int winPosX, int winPosY, Qt::Keyboard
|
||||
}
|
||||
}
|
||||
|
||||
bool isComparisonViewPick = m_viewer->isMousePosWithinComparisonView( winPosX, winPosY );
|
||||
Rim3dView* mainOrComparisonView = isComparisonViewPick ? m_reservoirView->activeComparisonView()
|
||||
: m_reservoirView.p();
|
||||
|
||||
// Make pickEventHandlers do their stuff
|
||||
|
||||
if ( pickItemInfos.size() )
|
||||
{
|
||||
Ric3dPickEvent viewerEventObject( pickItemInfos, m_reservoirView );
|
||||
Ric3dPickEvent viewerEventObject( pickItemInfos, mainOrComparisonView );
|
||||
|
||||
if ( sm_overridingPickHandler && sm_overridingPickHandler->handle3dPickEvent( viewerEventObject ) )
|
||||
{
|
||||
@@ -630,7 +640,7 @@ void RiuViewerCommands::handlePickAction( int winPosX, int winPosY, Qt::Keyboard
|
||||
size_t indexToNncItemNearFirstItem = cvf::UNDEFINED_SIZE_T;
|
||||
;
|
||||
|
||||
findFirstItems( pickItemInfos, &indexToFirstNoneNncItem, &indexToNncItemNearFirstItem );
|
||||
findFirstItems( mainOrComparisonView, pickItemInfos, &indexToFirstNoneNncItem, &indexToNncItemNearFirstItem );
|
||||
|
||||
if ( indexToFirstNoneNncItem != cvf::UNDEFINED_SIZE_T )
|
||||
{
|
||||
@@ -716,10 +726,10 @@ void RiuViewerCommands::handlePickAction( int winPosX, int winPosY, Qt::Keyboard
|
||||
// Set fracture resultInfo text
|
||||
QString resultInfoText;
|
||||
|
||||
cvf::ref<caf::DisplayCoordTransform> transForm = m_reservoirView->displayCoordTransform();
|
||||
cvf::ref<caf::DisplayCoordTransform> transForm = mainOrComparisonView->displayCoordTransform();
|
||||
cvf::Vec3d domainCoord = transForm->transformToDomainCoord( globalIntersectionPoint );
|
||||
|
||||
RimEclipseView* eclView = dynamic_cast<RimEclipseView*>( m_reservoirView.p() );
|
||||
RimEclipseView* eclView = dynamic_cast<RimEclipseView*>( mainOrComparisonView );
|
||||
RivWellFracturePartMgr* partMgr = fracture->fracturePartManager();
|
||||
if ( eclView ) resultInfoText = partMgr->resultInfoText( *eclView, domainCoord );
|
||||
|
||||
@@ -763,7 +773,11 @@ void RiuViewerCommands::handlePickAction( int winPosX, int winPosY, Qt::Keyboard
|
||||
}
|
||||
else if ( crossSectionSourceInfo )
|
||||
{
|
||||
findCellAndGridIndex( crossSectionSourceInfo, firstPartTriangleIndex, &cellIndex, &gridIndex );
|
||||
findCellAndGridIndex( mainOrComparisonView,
|
||||
crossSectionSourceInfo,
|
||||
firstPartTriangleIndex,
|
||||
&cellIndex,
|
||||
&gridIndex );
|
||||
intersectionHit = true;
|
||||
intersectionTriangleHit = crossSectionSourceInfo->triangle( firstPartTriangleIndex );
|
||||
|
||||
@@ -775,7 +789,11 @@ void RiuViewerCommands::handlePickAction( int winPosX, int winPosY, Qt::Keyboard
|
||||
}
|
||||
else if ( intersectionBoxSourceInfo )
|
||||
{
|
||||
findCellAndGridIndex( intersectionBoxSourceInfo, firstPartTriangleIndex, &cellIndex, &gridIndex );
|
||||
findCellAndGridIndex( mainOrComparisonView,
|
||||
intersectionBoxSourceInfo,
|
||||
firstPartTriangleIndex,
|
||||
&cellIndex,
|
||||
&gridIndex );
|
||||
intersectionHit = true;
|
||||
intersectionTriangleHit = intersectionBoxSourceInfo->triangle( firstPartTriangleIndex );
|
||||
|
||||
@@ -796,7 +814,7 @@ void RiuViewerCommands::handlePickAction( int winPosX, int winPosY, Qt::Keyboard
|
||||
size_t globalCellIndex = wellConnectionSourceInfo->globalCellIndexFromTriangleIndex(
|
||||
firstPartTriangleIndex );
|
||||
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( m_reservoirView.p() );
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( mainOrComparisonView );
|
||||
if ( eclipseView )
|
||||
{
|
||||
RimEclipseCase* eclipseCase = nullptr;
|
||||
@@ -875,7 +893,7 @@ void RiuViewerCommands::handlePickAction( int winPosX, int winPosY, Qt::Keyboard
|
||||
double connectionFactor = simWellConnectionSourceInfo->connectionFactorFromTriangleIndex(
|
||||
firstPartTriangleIndex );
|
||||
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( m_reservoirView.p() );
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( mainOrComparisonView );
|
||||
if ( eclipseView )
|
||||
{
|
||||
RimEclipseCase* eclipseCase = nullptr;
|
||||
@@ -949,9 +967,9 @@ void RiuViewerCommands::handlePickAction( int winPosX, int winPosY, Qt::Keyboard
|
||||
|
||||
RiuSelectionItem* selItem = nullptr;
|
||||
{
|
||||
Rim2dIntersectionView* intersectionView = dynamic_cast<Rim2dIntersectionView*>( m_reservoirView.p() );
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( m_reservoirView.p() );
|
||||
RimGeoMechView* geomView = dynamic_cast<RimGeoMechView*>( m_reservoirView.p() );
|
||||
Rim2dIntersectionView* intersectionView = dynamic_cast<Rim2dIntersectionView*>( mainOrComparisonView );
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( mainOrComparisonView );
|
||||
RimGeoMechView* geomView = dynamic_cast<RimGeoMechView*>( mainOrComparisonView );
|
||||
|
||||
if ( intersectionView )
|
||||
{
|
||||
@@ -1063,14 +1081,15 @@ void RiuViewerCommands::removeDefaultPickEventHandler( RicDefaultPickEventHandle
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewerCommands::findCellAndGridIndex( const RivIntersectionSourceInfo* crossSectionSourceInfo,
|
||||
void RiuViewerCommands::findCellAndGridIndex( Rim3dView* mainOrComparisonView,
|
||||
const RivIntersectionSourceInfo* crossSectionSourceInfo,
|
||||
cvf::uint firstPartTriangleIndex,
|
||||
size_t* cellIndex,
|
||||
size_t* gridIndex )
|
||||
{
|
||||
CVF_ASSERT( cellIndex && gridIndex );
|
||||
|
||||
RimCase* ownerCase = m_reservoirView->ownerCase();
|
||||
RimCase* ownerCase = mainOrComparisonView->ownerCase();
|
||||
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>( ownerCase );
|
||||
RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>( ownerCase );
|
||||
if ( eclipseCase )
|
||||
@@ -1094,15 +1113,17 @@ void RiuViewerCommands::findCellAndGridIndex( const RivIntersectionSourceInfo* c
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewerCommands::findCellAndGridIndex( const RivIntersectionBoxSourceInfo* intersectionBoxSourceInfo,
|
||||
void RiuViewerCommands::findCellAndGridIndex( Rim3dView* mainOrComparisonView,
|
||||
const RivIntersectionBoxSourceInfo* intersectionBoxSourceInfo,
|
||||
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() );
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( mainOrComparisonView );
|
||||
RimGeoMechView* geomView = dynamic_cast<RimGeoMechView*>( mainOrComparisonView );
|
||||
|
||||
if ( eclipseView )
|
||||
{
|
||||
size_t globalCellIndex = intersectionBoxSourceInfo->triangleToCellIndex()[firstPartTriangleIndex];
|
||||
@@ -1121,7 +1142,8 @@ void RiuViewerCommands::findCellAndGridIndex( const RivIntersectionBoxSourceInfo
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewerCommands::findFirstItems( const std::vector<RiuPickItemInfo>& pickItemInfos,
|
||||
void RiuViewerCommands::findFirstItems( Rim3dView* mainOrComparisonView,
|
||||
const std::vector<RiuPickItemInfo>& pickItemInfos,
|
||||
size_t* indexToFirstNoneNncItem,
|
||||
size_t* indexToNncItemNearFirsItem )
|
||||
{
|
||||
@@ -1131,7 +1153,7 @@ void RiuViewerCommands::findFirstItems( const std::vector<RiuPickItemInfo>& pick
|
||||
|
||||
double pickDepthThresholdSquared = 0.05 * 0.05;
|
||||
{
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( m_reservoirView.p() );
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( mainOrComparisonView );
|
||||
|
||||
if ( eclipseView && eclipseView->mainGrid() )
|
||||
{
|
||||
@@ -1195,10 +1217,11 @@ void RiuViewerCommands::findFirstItems( const std::vector<RiuPickItemInfo>& pick
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuViewerCommands::ijkFromCellIndex( size_t gridIdx, size_t cellIndex, size_t* i, size_t* j, size_t* k )
|
||||
void RiuViewerCommands::ijkFromCellIndex(
|
||||
Rim3dView* mainOrComparisonView, size_t gridIdx, size_t cellIndex, size_t* i, size_t* j, size_t* k )
|
||||
{
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( m_reservoirView.p() );
|
||||
RimGeoMechView* geomView = dynamic_cast<RimGeoMechView*>( m_reservoirView.p() );
|
||||
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( mainOrComparisonView );
|
||||
RimGeoMechView* geomView = dynamic_cast<RimGeoMechView*>( mainOrComparisonView );
|
||||
|
||||
if ( eclipseView && eclipseView->eclipseCase() )
|
||||
{
|
||||
@@ -1232,6 +1255,13 @@ bool RiuViewerCommands::handleOverlayItemPicking( int winPosX, int winPosY )
|
||||
else
|
||||
{
|
||||
std::vector<RimLegendConfig*> legendConfigs = m_reservoirView->legendConfigs();
|
||||
if ( m_reservoirView->activeComparisonView() )
|
||||
{
|
||||
std::vector<RimLegendConfig*> compViewLegendConfigs = m_reservoirView->activeComparisonView()
|
||||
->legendConfigs();
|
||||
legendConfigs.insert( legendConfigs.end(), compViewLegendConfigs.begin(), compViewLegendConfigs.end() );
|
||||
}
|
||||
|
||||
for ( const auto& legendConfig : legendConfigs )
|
||||
{
|
||||
if ( legendConfig && legendConfig->titledOverlayFrame() == pickedOverlayItem )
|
||||
@@ -1254,10 +1284,13 @@ void RiuViewerCommands::handleTextPicking( int winPosX, int winPosY, cvf::HitIte
|
||||
{
|
||||
using namespace cvf;
|
||||
|
||||
bool isMouseWithinComparisonView = m_viewer->isMousePosWithinComparisonView( winPosX, winPosY );
|
||||
|
||||
int translatedMousePosX = winPosX;
|
||||
int translatedMousePosY = m_viewer->height() - winPosY;
|
||||
|
||||
Scene* scene = m_viewer->currentScene();
|
||||
Scene* scene = m_viewer->currentScene( isMouseWithinComparisonView );
|
||||
|
||||
if ( !scene ) return;
|
||||
|
||||
Collection<Part> partCollection;
|
||||
|
||||
@@ -68,18 +68,21 @@ public:
|
||||
cvf::Vec3d lastPickPositionInDomainCoords() const;
|
||||
|
||||
private:
|
||||
void findCellAndGridIndex( const RivIntersectionSourceInfo* crossSectionSourceInfo,
|
||||
void findCellAndGridIndex( Rim3dView* mainOrComparisonView,
|
||||
const RivIntersectionSourceInfo* crossSectionSourceInfo,
|
||||
cvf::uint firstPartTriangleIndex,
|
||||
size_t* cellIndex,
|
||||
size_t* gridIndex );
|
||||
void findCellAndGridIndex( const RivIntersectionBoxSourceInfo* intersectionBoxSourceInfo,
|
||||
void findCellAndGridIndex( Rim3dView* mainOrComparisonView,
|
||||
const RivIntersectionBoxSourceInfo* intersectionBoxSourceInfo,
|
||||
cvf::uint firstPartTriangleIndex,
|
||||
size_t* cellIndex,
|
||||
size_t* gridIndex );
|
||||
void ijkFromCellIndex(
|
||||
Rim3dView* mainOrComparisonView, size_t gridIdx, size_t cellIndex, size_t* i, size_t* j, size_t* k );
|
||||
|
||||
void ijkFromCellIndex( size_t gridIdx, size_t cellIndex, size_t* i, size_t* j, size_t* k );
|
||||
|
||||
void findFirstItems( const std::vector<RiuPickItemInfo>& pickItemInfos,
|
||||
void findFirstItems( Rim3dView* mainOrComparisonView,
|
||||
const std::vector<RiuPickItemInfo>& pickItemInfos,
|
||||
size_t* indexToFirstNoneNncItem,
|
||||
size_t* indexToNncItemNearFirsItem );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user