(#5112) Move cell and nnc picking code to a separate pick event handler

This commit is contained in:
Jacob Støren 2019-11-25 18:36:05 +01:00
parent dc2af5e0c8
commit 8cc2194764
8 changed files with 369 additions and 212 deletions

View File

@ -41,14 +41,16 @@ class Rim3dView;
class Ric3dPickEvent : public caf::PickEvent
{
public:
Ric3dPickEvent( const std::vector<RiuPickItemInfo>& pickItemInfos, Rim3dView* view )
Ric3dPickEvent( const std::vector<RiuPickItemInfo>& pickItemInfos, Rim3dView* view, Qt::KeyboardModifiers keyboardModifiers)
: m_pickItemInfos( pickItemInfos )
, m_view( view )
, m_keyboardModifiers( keyboardModifiers )
{
}
std::vector<RiuPickItemInfo> m_pickItemInfos;
Rim3dView* m_view;
Qt::KeyboardModifiers m_keyboardModifiers;
};
//==================================================================================================

View File

@ -48,6 +48,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuTreeViewEventFilter.h
${CMAKE_CURRENT_LIST_DIR}/RiuViewer.h
${CMAKE_CURRENT_LIST_DIR}/RiuViewerToViewInterface.h
${CMAKE_CURRENT_LIST_DIR}/RiuViewerCommands.h
${CMAKE_CURRENT_LIST_DIR}/RiuCellAndNncPickEventHandler.h
${CMAKE_CURRENT_LIST_DIR}/RiuPickItemInfo.h
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.h
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.h
@ -136,6 +137,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiuToolTipMenu.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuTreeViewEventFilter.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuViewer.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuViewerCommands.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuCellAndNncPickEventHandler.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuPickItemInfo.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.cpp
${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.cpp

View File

@ -25,6 +25,8 @@
#include "RimGridView.h"
#include "RimSimWellInView.h"
#include "RimWellPath.h"
#include "RimEclipseResultDefinition.h"
#include "RimGeoMechResultDefinition.h"
#include "RivSimWellPipeSourceInfo.h"
#include "RivWellPathSourceInfo.h"
@ -156,6 +158,8 @@ void Riu3dSelectionManager::deleteAllItemsFromSelection( int role )
///
//--------------------------------------------------------------------------------------------------
RiuEclipseSelectionItem::RiuEclipseSelectionItem( RimEclipseView* view,
RimEclipseResultDefinition* resultDefinition,
size_t timestepIdx,
size_t gridIndex,
size_t cellIndex,
size_t nncIndex,
@ -163,6 +167,8 @@ RiuEclipseSelectionItem::RiuEclipseSelectionItem( RimEclipseView*
cvf::StructGridInterface::FaceType face,
const cvf::Vec3d& localIntersectionPointInDisplay )
: m_view( view )
, m_resultDefinition( resultDefinition )
, m_timestepIdx( timestepIdx )
, m_gridIndex( gridIndex )
, m_gridLocalCellIndex( cellIndex )
, m_nncIndex( nncIndex )
@ -175,13 +181,17 @@ RiuEclipseSelectionItem::RiuEclipseSelectionItem( RimEclipseView*
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGeoMechView* view,
size_t gridIndex,
size_t cellIndex,
cvf::Color3f color,
int elementFace,
const cvf::Vec3d& localIntersectionPointInDisplay )
RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGeoMechView* view,
RimGeoMechResultDefinition* resultDefinition,
size_t timestepIdx,
size_t gridIndex,
size_t cellIndex,
cvf::Color3f color,
int elementFace,
const cvf::Vec3d& localIntersectionPointInDisplay )
: m_view( view )
, m_resultDefinition( resultDefinition )
, m_timestepIdx( timestepIdx )
, m_gridIndex( gridIndex )
, m_cellIndex( cellIndex )
, m_color( color )
@ -195,6 +205,8 @@ RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGeoMechView* view,
///
//--------------------------------------------------------------------------------------------------
RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGeoMechView* view,
RimGeoMechResultDefinition* resultDefinition,
size_t timestepIdx,
size_t gridIndex,
size_t cellIndex,
cvf::Color3f color,
@ -202,6 +214,8 @@ RiuGeoMechSelectionItem::RiuGeoMechSelectionItem( RimGeoMechView*
const cvf::Vec3d& localIntersectionPointInDisplay,
const std::array<cvf::Vec3f, 3>& intersectionTriangle )
: m_view( view )
, m_resultDefinition( resultDefinition )
, m_timestepIdx( timestepIdx )
, m_gridIndex( gridIndex )
, m_cellIndex( cellIndex )
, m_color( color )

View File

@ -42,6 +42,8 @@ class RiuSelectionChangedHandler;
class RiuSelectionItem;
class RivSimWellPipeSourceInfo;
class RivWellPathSourceInfo;
class RimEclipseResultDefinition;
class RimGeoMechResultDefinition;
//==================================================================================================
//
@ -131,6 +133,8 @@ class RiuEclipseSelectionItem : public RiuSelectionItem
{
public:
explicit RiuEclipseSelectionItem( RimEclipseView* view,
RimEclipseResultDefinition* resultDefinition,
size_t timestepIdx,
size_t gridIndex,
size_t cellIndex,
size_t nncIndex,
@ -146,13 +150,15 @@ public:
}
public:
caf::PdmPointer<RimEclipseView> m_view;
size_t m_gridIndex;
size_t m_gridLocalCellIndex;
size_t m_nncIndex;
cvf::Color3f m_color;
cvf::StructGridInterface::FaceType m_face;
cvf::Vec3d m_localIntersectionPointInDisplay;
caf::PdmPointer<RimEclipseView> m_view;
caf::PdmPointer<RimEclipseResultDefinition> m_resultDefinition;
size_t m_timestepIdx;
size_t m_gridIndex;
size_t m_gridLocalCellIndex;
size_t m_nncIndex;
cvf::Color3f m_color;
cvf::StructGridInterface::FaceType m_face;
cvf::Vec3d m_localIntersectionPointInDisplay;
};
//==================================================================================================
@ -163,14 +169,18 @@ public:
class RiuGeoMechSelectionItem : public RiuSelectionItem
{
public:
explicit RiuGeoMechSelectionItem( RimGeoMechView* view,
size_t gridIndex,
size_t cellIndex,
cvf::Color3f color,
int elementFace,
const cvf::Vec3d& localIntersectionPointInDisplay );
explicit RiuGeoMechSelectionItem( RimGeoMechView* view,
RimGeoMechResultDefinition* resultDefinition,
size_t timestepIdx,
size_t gridIndex,
size_t cellIndex,
cvf::Color3f color,
int elementFace,
const cvf::Vec3d& localIntersectionPointInDisplay );
explicit RiuGeoMechSelectionItem( RimGeoMechView* view,
RimGeoMechResultDefinition* resultDefinition,
size_t timestepIdx,
size_t gridIndex,
size_t cellIndex,
cvf::Color3f color,
@ -185,14 +195,16 @@ public:
}
public:
caf::PdmPointer<RimGeoMechView> m_view;
size_t m_gridIndex;
size_t m_cellIndex;
cvf::Color3f m_color;
int m_elementFace;
bool m_hasIntersectionTriangle;
std::array<cvf::Vec3f, 3> m_intersectionTriangle;
cvf::Vec3d m_localIntersectionPointInDisplay;
caf::PdmPointer<RimGeoMechView> m_view;
caf::PdmPointer<RimGeoMechResultDefinition> m_resultDefinition;
size_t m_timestepIdx;
size_t m_gridIndex;
size_t m_cellIndex;
cvf::Color3f m_color;
int m_elementFace;
bool m_hasIntersectionTriangle;
std::array<cvf::Vec3f, 3> m_intersectionTriangle;
cvf::Vec3d m_localIntersectionPointInDisplay;
};
//==================================================================================================

View File

@ -0,0 +1,247 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- Equinor ASA
//
// 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 "RiuCellAndNncPickEventHandler.h"
#include "RiaColorTables.h"
#include "Rim2dIntersectionView.h"
#include "RimEclipseView.h"
#include "RimExtrudedCurveIntersection.h"
#include "RimGeoMechView.h"
#include "Riu3dSelectionManager.h"
#include "RiuViewerCommands.h"
#include "RivBoxIntersectionSourceInfo.h"
#include "RivExtrudedCurveIntersectionSourceInfo.h"
#include "RivFemPartGeometryGenerator.h"
#include "RivFemPickSourceInfo.h"
#include "RivSourceInfo.h"
#include "cafPdmObjectHandle.h"
#include "cvfPart.h"
#include <array>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuCellAndNncPickEventHandler* RiuCellAndNncPickEventHandler::instance()
{
static RiuCellAndNncPickEventHandler* singleton = new RiuCellAndNncPickEventHandler;
return singleton;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuCellAndNncPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eventObject )
{
const std::vector<RiuPickItemInfo>& pickItemInfos = eventObject.m_pickItemInfos;
Rim3dView* mainOrComparisonView = eventObject.m_view;
Qt::KeyboardModifiers keyboardModifiers = eventObject.m_keyboardModifiers;
const cvf::Part* firstHitPart = nullptr;
uint firstPartTriangleIndex = cvf::UNDEFINED_UINT;
cvf::Vec3d localIntersectionPoint( cvf::Vec3d::ZERO );
cvf::Vec3d globalIntersectionPoint( cvf::Vec3d::ZERO );
size_t nncIndex = cvf::UNDEFINED_SIZE_T;
{
const cvf::Part* firstNncHitPart = nullptr;
uint nncPartTriangleIndex = cvf::UNDEFINED_UINT;
if ( pickItemInfos.size() )
{
size_t indexToFirstNoneNncItem = cvf::UNDEFINED_SIZE_T;
size_t indexToNncItemNearFirstItem = cvf::UNDEFINED_SIZE_T;
RiuViewerCommands::findFirstItems( mainOrComparisonView,
pickItemInfos,
&indexToFirstNoneNncItem,
&indexToNncItemNearFirstItem );
if ( indexToFirstNoneNncItem != cvf::UNDEFINED_SIZE_T )
{
localIntersectionPoint = pickItemInfos[indexToFirstNoneNncItem].localPickedPoint();
globalIntersectionPoint = pickItemInfos[indexToFirstNoneNncItem].globalPickedPoint();
firstHitPart = pickItemInfos[indexToFirstNoneNncItem].pickedPart();
firstPartTriangleIndex = pickItemInfos[indexToFirstNoneNncItem].faceIdx();
}
if ( indexToNncItemNearFirstItem != cvf::UNDEFINED_SIZE_T )
{
firstNncHitPart = pickItemInfos[indexToNncItemNearFirstItem].pickedPart();
nncPartTriangleIndex = pickItemInfos[indexToNncItemNearFirstItem].faceIdx();
}
}
if ( firstNncHitPart && firstNncHitPart->sourceInfo() )
{
const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>( firstNncHitPart->sourceInfo() );
if ( rivSourceInfo )
{
if ( nncPartTriangleIndex < rivSourceInfo->m_NNCIndices->size() )
{
nncIndex = rivSourceInfo->m_NNCIndices->get( nncPartTriangleIndex );
}
}
}
}
if ( !firstHitPart ) return false;
size_t gridIndex = cvf::UNDEFINED_SIZE_T;
size_t cellIndex = cvf::UNDEFINED_SIZE_T;
cvf::StructGridInterface::FaceType face = cvf::StructGridInterface::NO_FACE;
int gmFace = -1;
bool intersectionHit = false;
std::array<cvf::Vec3f, 3> intersectionTriangleHit;
// clang-format off
if ( const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>( firstHitPart->sourceInfo() ) )
{
gridIndex = rivSourceInfo->gridIndex();
if ( rivSourceInfo->hasCellFaceMapping() )
{
CVF_ASSERT( rivSourceInfo->m_cellFaceFromTriangleMapper.notNull() );
cellIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellIndex( firstPartTriangleIndex );
face = rivSourceInfo->m_cellFaceFromTriangleMapper->cellFace( firstPartTriangleIndex );
}
}
else if ( const RivFemPickSourceInfo* femSourceInfo =
dynamic_cast<const RivFemPickSourceInfo*>( firstHitPart->sourceInfo() ) )
{
gridIndex = femSourceInfo->femPartIndex();
cellIndex = femSourceInfo->triangleToElmMapper()->elementIndex( firstPartTriangleIndex );
gmFace = femSourceInfo->triangleToElmMapper()->elementFace( firstPartTriangleIndex );
}
else if ( const RivExtrudedCurveIntersectionSourceInfo* crossSectionSourceInfo =
dynamic_cast<const RivExtrudedCurveIntersectionSourceInfo*>( firstHitPart->sourceInfo() ) )
{
RiuViewerCommands::findCellAndGridIndex( mainOrComparisonView,
crossSectionSourceInfo,
firstPartTriangleIndex,
&cellIndex,
&gridIndex );
intersectionHit = true;
intersectionTriangleHit = crossSectionSourceInfo->triangle( firstPartTriangleIndex );
}
else if ( const RivBoxIntersectionSourceInfo* intersectionBoxSourceInfo =
dynamic_cast<const RivBoxIntersectionSourceInfo*>( firstHitPart->sourceInfo() ) )
{
RiuViewerCommands::findCellAndGridIndex( mainOrComparisonView,
intersectionBoxSourceInfo,
firstPartTriangleIndex,
&cellIndex,
&gridIndex );
intersectionHit = true;
intersectionTriangleHit = intersectionBoxSourceInfo->triangle( firstPartTriangleIndex );
}
// clang-format on
if ( cellIndex == cvf::UNDEFINED_SIZE_T )
{
Riu3dSelectionManager::instance()->deleteAllItems();
return false;
}
bool appendToSelection = false;
if ( keyboardModifiers & Qt::ControlModifier )
{
appendToSelection = true;
}
std::vector<RiuSelectionItem*> items;
Riu3dSelectionManager::instance()->selectedItems( items );
const caf::ColorTable& colorTable = RiaColorTables::selectionPaletteColors();
cvf::Color3f curveColor = colorTable.cycledColor3f( items.size() );
if ( !appendToSelection )
{
curveColor = colorTable.cycledColor3f( 0 );
}
RiuSelectionItem* selItem = nullptr;
{
Rim2dIntersectionView* intersectionView = dynamic_cast<Rim2dIntersectionView*>( mainOrComparisonView );
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( mainOrComparisonView );
RimGeoMechView* geomView = dynamic_cast<RimGeoMechView*>( mainOrComparisonView );
if ( intersectionView )
{
intersectionView->intersection()->firstAncestorOrThisOfType( eclipseView );
intersectionView->intersection()->firstAncestorOrThisOfType( geomView );
}
if ( eclipseView )
{
selItem = new RiuEclipseSelectionItem( eclipseView,
nullptr,
-1,
gridIndex,
cellIndex,
nncIndex,
curveColor,
face,
localIntersectionPoint );
}
if ( geomView )
{
if ( intersectionHit )
selItem = new RiuGeoMechSelectionItem( geomView,
nullptr,
-1,
gridIndex,
cellIndex,
curveColor,
gmFace,
localIntersectionPoint,
intersectionTriangleHit );
else
selItem = new RiuGeoMechSelectionItem( geomView,
nullptr,
-1,
gridIndex,
cellIndex,
curveColor,
gmFace,
localIntersectionPoint );
}
if ( intersectionView ) selItem = new Riu2dIntersectionSelectionItem( intersectionView, selItem );
}
if ( appendToSelection )
{
Riu3dSelectionManager::instance()->appendItemToSelection( selItem );
}
else if ( selItem )
{
Riu3dSelectionManager::instance()->setSelectedItem( selItem );
}
return false;
}

View File

@ -0,0 +1,33 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- Equinor ASA
//
// 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 "RicPickEventHandler.h"
//==================================================================================================
///
//==================================================================================================
class RiuCellAndNncPickEventHandler : public RicDefaultPickEventHandler
{
public:
static RiuCellAndNncPickEventHandler* instance();
protected:
bool handle3dPickEvent( const Ric3dPickEvent& eventObject ) override;
};

View File

@ -28,6 +28,7 @@
#include "RicEclipsePropertyFilterNewExec.h"
#include "RicGeoMechPropertyFilterNewExec.h"
#include "RicPickEventHandler.h"
#include "RiuCellAndNncPickEventHandler.h"
#include "WellLogCommands/Ric3dWellLogCurvePickEventHandler.h"
#include "WellPathCommands/RicIntersectionPickEventHandler.h"
#include "WellPathCommands/RicWellPathPickEventHandler.h"
@ -137,6 +138,7 @@ RiuViewerCommands::RiuViewerCommands( RiuViewer* ownerViewer )
addDefaultPickEventHandler( Ric3dWellLogCurvePickEventHandler::instance() );
addDefaultPickEventHandler( RicWellPathPickEventHandler::instance() );
addDefaultPickEventHandler( RicContourMapPickEventHandler::instance() );
addDefaultPickEventHandler( RiuCellAndNncPickEventHandler::instance() );
}
}
@ -643,7 +645,7 @@ void RiuViewerCommands::handlePickAction( int winPosX, int winPosY, Qt::Keyboard
if ( pickItemInfos.size() )
{
Ric3dPickEvent viewerEventObject( pickItemInfos, mainOrComparisonView );
Ric3dPickEvent viewerEventObject( pickItemInfos, mainOrComparisonView, keyboardModifiers );
if ( sm_overridingPickHandler && sm_overridingPickHandler->handle3dPickEvent( viewerEventObject ) )
{
@ -660,77 +662,33 @@ void RiuViewerCommands::handlePickAction( int winPosX, int winPosY, Qt::Keyboard
}
// Old pick handling. Todo: Encapsulate in pickEventHandlers
size_t gridIndex = cvf::UNDEFINED_SIZE_T;
size_t cellIndex = cvf::UNDEFINED_SIZE_T;
size_t nncIndex = cvf::UNDEFINED_SIZE_T;
cvf::StructGridInterface::FaceType face = cvf::StructGridInterface::NO_FACE;
int gmFace = -1;
bool intersectionHit = false;
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
{
const cvf::Part* firstHitPart = nullptr;
uint firstPartTriangleIndex = cvf::UNDEFINED_UINT;
const cvf::Part* firstNncHitPart = nullptr;
uint nncPartTriangleIndex = cvf::UNDEFINED_UINT;
cvf::Vec3d globalIntersectionPoint( cvf::Vec3d::ZERO );
if ( pickItemInfos.size() )
{
size_t indexToFirstNoneNncItem = cvf::UNDEFINED_SIZE_T;
;
size_t indexToFirstNoneNncItem = cvf::UNDEFINED_SIZE_T;
size_t indexToNncItemNearFirstItem = cvf::UNDEFINED_SIZE_T;
;
findFirstItems( mainOrComparisonView, pickItemInfos, &indexToFirstNoneNncItem, &indexToNncItemNearFirstItem );
if ( indexToFirstNoneNncItem != cvf::UNDEFINED_SIZE_T )
{
localIntersectionPoint = pickItemInfos[indexToFirstNoneNncItem].localPickedPoint();
globalIntersectionPoint = pickItemInfos[indexToFirstNoneNncItem].globalPickedPoint();
firstHitPart = pickItemInfos[indexToFirstNoneNncItem].pickedPart();
firstPartTriangleIndex = pickItemInfos[indexToFirstNoneNncItem].faceIdx();
}
if ( indexToNncItemNearFirstItem != cvf::UNDEFINED_SIZE_T )
{
firstNncHitPart = pickItemInfos[indexToNncItemNearFirstItem].pickedPart();
nncPartTriangleIndex = pickItemInfos[indexToNncItemNearFirstItem].faceIdx();
}
}
if ( firstNncHitPart && firstNncHitPart->sourceInfo() )
{
const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>( firstNncHitPart->sourceInfo() );
if ( rivSourceInfo )
{
if ( nncPartTriangleIndex < rivSourceInfo->m_NNCIndices->size() )
{
nncIndex = rivSourceInfo->m_NNCIndices->get( nncPartTriangleIndex );
}
globalIntersectionPoint = pickItemInfos[indexToFirstNoneNncItem].globalPickedPoint();
}
}
if ( firstHitPart && firstHitPart->sourceInfo() )
{
const RivObjectSourceInfo* rivObjectSourceInfo = dynamic_cast<const RivObjectSourceInfo*>(
firstHitPart->sourceInfo() );
const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>( firstHitPart->sourceInfo() );
const RivFemPickSourceInfo* femSourceInfo = dynamic_cast<const RivFemPickSourceInfo*>(
firstHitPart->sourceInfo() );
const RivExtrudedCurveIntersectionSourceInfo* crossSectionSourceInfo =
dynamic_cast<const RivExtrudedCurveIntersectionSourceInfo*>( firstHitPart->sourceInfo() );
const RivBoxIntersectionSourceInfo* intersectionBoxSourceInfo =
dynamic_cast<const RivBoxIntersectionSourceInfo*>( firstHitPart->sourceInfo() );
const RivSimWellPipeSourceInfo* eclipseWellSourceInfo = dynamic_cast<const RivSimWellPipeSourceInfo*>(
firstHitPart->sourceInfo() );
const RivWellConnectionSourceInfo* wellConnectionSourceInfo = dynamic_cast<const RivWellConnectionSourceInfo*>(
firstHitPart->sourceInfo() );
// clang-format off
const RivObjectSourceInfo* rivObjectSourceInfo = dynamic_cast<const RivObjectSourceInfo*>( firstHitPart->sourceInfo() );
const RivSimWellPipeSourceInfo* eclipseWellSourceInfo = dynamic_cast<const RivSimWellPipeSourceInfo*>( firstHitPart->sourceInfo() );
const RivWellConnectionSourceInfo* wellConnectionSourceInfo = dynamic_cast<const RivWellConnectionSourceInfo*>( firstHitPart->sourceInfo() );
// clang-format on
if ( rivObjectSourceInfo )
{
@ -800,50 +758,18 @@ void RiuViewerCommands::handlePickAction( int winPosX, int winPosY, Qt::Keyboard
RiuMainWindow::instance()->selectAsCurrentItem( textAnnot, true );
}
}
if ( rivSourceInfo )
else if ( const RivExtrudedCurveIntersectionSourceInfo* crossSectionSourceInfo =
dynamic_cast<const RivExtrudedCurveIntersectionSourceInfo*>( firstHitPart->sourceInfo() ) )
{
gridIndex = rivSourceInfo->gridIndex();
if ( rivSourceInfo->hasCellFaceMapping() )
{
CVF_ASSERT( rivSourceInfo->m_cellFaceFromTriangleMapper.notNull() );
cellIndex = rivSourceInfo->m_cellFaceFromTriangleMapper->cellIndex( firstPartTriangleIndex );
face = rivSourceInfo->m_cellFaceFromTriangleMapper->cellFace( firstPartTriangleIndex );
}
}
else if ( femSourceInfo )
{
gridIndex = femSourceInfo->femPartIndex();
cellIndex = femSourceInfo->triangleToElmMapper()->elementIndex( firstPartTriangleIndex );
gmFace = femSourceInfo->triangleToElmMapper()->elementFace( firstPartTriangleIndex );
}
else if ( crossSectionSourceInfo )
{
findCellAndGridIndex( mainOrComparisonView,
crossSectionSourceInfo,
firstPartTriangleIndex,
&cellIndex,
&gridIndex );
intersectionHit = true;
intersectionTriangleHit = crossSectionSourceInfo->triangle( firstPartTriangleIndex );
bool allowActiveViewChange = dynamic_cast<Rim2dIntersectionView*>( m_viewer->ownerViewWindow() ) ==
nullptr;
RiuMainWindow::instance()->selectAsCurrentItem( crossSectionSourceInfo->intersection(),
allowActiveViewChange );
}
else if ( intersectionBoxSourceInfo )
else if ( const RivBoxIntersectionSourceInfo* intersectionBoxSourceInfo =
dynamic_cast<const RivBoxIntersectionSourceInfo*>( firstHitPart->sourceInfo() ) )
{
findCellAndGridIndex( mainOrComparisonView,
intersectionBoxSourceInfo,
firstPartTriangleIndex,
&cellIndex,
&gridIndex );
intersectionHit = true;
intersectionTriangleHit = intersectionBoxSourceInfo->triangle( firstPartTriangleIndex );
RiuMainWindow::instance()->selectAsCurrentItem( intersectionBoxSourceInfo->intersectionBox() );
}
else if ( eclipseWellSourceInfo )
@ -987,85 +913,6 @@ void RiuViewerCommands::handlePickAction( int winPosX, int winPosY, Qt::Keyboard
}
}
}
if ( cellIndex == cvf::UNDEFINED_SIZE_T )
{
Riu3dSelectionManager::instance()->deleteAllItems();
}
else
{
bool appendToSelection = false;
if ( keyboardModifiers & Qt::ControlModifier )
{
appendToSelection = true;
}
std::vector<RiuSelectionItem*> items;
Riu3dSelectionManager::instance()->selectedItems( items );
const caf::ColorTable& colorTable = RiaColorTables::selectionPaletteColors();
cvf::Color3f curveColor = colorTable.cycledColor3f( items.size() );
if ( !appendToSelection )
{
curveColor = colorTable.cycledColor3f( 0 );
}
RiuSelectionItem* selItem = nullptr;
{
Rim2dIntersectionView* intersectionView = dynamic_cast<Rim2dIntersectionView*>( mainOrComparisonView );
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( mainOrComparisonView );
RimGeoMechView* geomView = dynamic_cast<RimGeoMechView*>( mainOrComparisonView );
if ( intersectionView )
{
intersectionView->intersection()->firstAncestorOrThisOfType( eclipseView );
intersectionView->intersection()->firstAncestorOrThisOfType( geomView );
}
if ( eclipseView )
{
selItem = new RiuEclipseSelectionItem( eclipseView,
gridIndex,
cellIndex,
nncIndex,
curveColor,
face,
localIntersectionPoint );
}
if ( geomView )
{
if ( intersectionHit )
selItem = new RiuGeoMechSelectionItem( geomView,
gridIndex,
cellIndex,
curveColor,
gmFace,
localIntersectionPoint,
intersectionTriangleHit );
else
selItem = new RiuGeoMechSelectionItem( geomView,
gridIndex,
cellIndex,
curveColor,
gmFace,
localIntersectionPoint );
}
if ( intersectionView ) selItem = new Riu2dIntersectionSelectionItem( intersectionView, selItem );
}
if ( appendToSelection )
{
Riu3dSelectionManager::instance()->appendItemToSelection( selItem );
}
else if ( selItem )
{
Riu3dSelectionManager::instance()->setSelectedItem( selItem );
}
}
}
//--------------------------------------------------------------------------------------------------

View File

@ -69,17 +69,22 @@ public:
cvf::Vec3d lastPickPositionInDomainCoords() const;
bool isCurrentPickInComparisonView() const;
static void findFirstItems( Rim3dView* mainOrComparisonView,
const std::vector<RiuPickItemInfo>& pickItemInfos,
size_t* indexToFirstNoneNncItem,
size_t* indexToNncItemNearFirsItem );
static void findCellAndGridIndex( Rim3dView* mainOrComparisonView,
const RivExtrudedCurveIntersectionSourceInfo* intersectionSourceInfo,
cvf::uint firstPartTriangleIndex,
size_t* cellIndex,
size_t* gridIndex );
static void findCellAndGridIndex( Rim3dView* mainOrComparisonView,
const RivBoxIntersectionSourceInfo* intersectionBoxSourceInfo,
cvf::uint firstPartTriangleIndex,
size_t* cellIndex,
size_t* gridIndex );
private:
void findCellAndGridIndex( Rim3dView* mainOrComparisonView,
const RivExtrudedCurveIntersectionSourceInfo* intersectionSourceInfo,
cvf::uint firstPartTriangleIndex,
size_t* cellIndex,
size_t* gridIndex );
void findCellAndGridIndex( Rim3dView* mainOrComparisonView,
const RivBoxIntersectionSourceInfo* intersectionBoxSourceInfo,
cvf::uint firstPartTriangleIndex,
size_t* cellIndex,
size_t* gridIndex );
void ijkFromCellIndex( Rim3dView* mainOrComparisonView,
size_t gridIdx,
size_t cellIndex,
@ -87,12 +92,8 @@ private:
size_t* j,
size_t* k );
void findFirstItems( Rim3dView* mainOrComparisonView,
const std::vector<RiuPickItemInfo>& pickItemInfos,
size_t* indexToFirstNoneNncItem,
size_t* indexToNncItemNearFirsItem );
bool handleOverlayItemPicking( int winPosX, int winPosY );
void handleTextPicking( int winPosX, int winPosY, cvf::HitItemCollection* hitItems );
void addCompareToViewMenu( caf::CmdFeatureMenuBuilder* menuBuilder );
@ -110,5 +111,4 @@ private:
static Ric3dViewPickEventHandler* sm_overridingPickHandler;
static std::vector<RicDefaultPickEventHandler*> sm_defaultPickEventHandlers;
void handleTextPicking( int winPosX, int winPosY, cvf::HitItemCollection* hitItems );
};