Fix eclipse case contour map left click (#11378)

* Make sure we operate in the correct domain when picking points in the contour map
This commit is contained in:
jonjenssen
2024-04-17 11:53:29 +02:00
committed by Magne Sjaastad
parent 62e497f5fc
commit 74f55c885b
3 changed files with 26 additions and 25 deletions

View File

@@ -61,34 +61,35 @@ bool RicContourMapPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eve
RimGridView* view = contourMap->firstAncestorOrThisOfTypeAsserted<RimGridView>();
if ( !view ) return false;
cvf::Vec2d pickedPoint;
const auto& firstPickItem = eventObject.m_pickItemInfos.front();
auto targetPointInDomain = view->displayCoordTransform()->transformToDomainCoord( firstPickItem.globalPickedPoint() );
QString curveText = QString( "%1\n" ).arg( view->createAutoName() );
cvf::Vec2d pickedPoint( cvf::Vec2d::UNDEFINED );
double valueAtPoint = 0.0;
if ( contourMap->checkForMapIntersection( firstPickedItem.globalPickedPoint(), &pickedPoint, &valueAtPoint ) )
if ( contourMap->checkForMapIntersection( targetPointInDomain, &pickedPoint, &valueAtPoint ) )
{
QString curveText;
curveText += QString( "%1\n" ).arg( view->createAutoName() );
curveText += QString( "Picked Point X, Y: %1, %2\n" ).arg( pickedPoint.x(), 5, 'f', 0 ).arg( pickedPoint.y(), 5, 'f', 0 );
curveText += QString( "Result Type: %1\n" ).arg( contourMap->resultDescriptionText() );
curveText += QString( "Aggregated Value: %1\n" ).arg( valueAtPoint );
RiuMainWindow::instance()->setResultInfo( curveText );
contourMap->setPickPoint( pickedPoint );
RimGeoMechContourMapView* geoMechContourView = dynamic_cast<RimGeoMechContourMapView*>( view );
RimEclipseContourMapView* eclipseContourView = dynamic_cast<RimEclipseContourMapView*>( view );
if ( geoMechContourView )
{
geoMechContourView->updatePickPointAndRedraw();
}
else if ( eclipseContourView )
{
eclipseContourView->updatePickPointAndRedraw();
}
return true;
}
contourMap->setPickPoint( cvf::Vec2d::UNDEFINED );
view->updateDisplayModelForCurrentTimeStepAndRedraw();
contourMap->setPickPoint( pickedPoint );
RimGeoMechContourMapView* geoMechContourView = dynamic_cast<RimGeoMechContourMapView*>( view );
RimEclipseContourMapView* eclipseContourView = dynamic_cast<RimEclipseContourMapView*>( view );
if ( geoMechContourView )
{
geoMechContourView->updatePickPointAndRedraw();
}
else if ( eclipseContourView )
{
eclipseContourView->updatePickPointAndRedraw();
}
RiuMainWindow::instance()->setResultInfo( curveText );
return true;
}

View File

@@ -399,12 +399,12 @@ size_t RimContourMapProjection::numberOfVertices() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimContourMapProjection::checkForMapIntersection( const cvf::Vec3d& localPoint3d, cvf::Vec2d* contourMapPoint, double* valueAtPoint ) const
bool RimContourMapProjection::checkForMapIntersection( const cvf::Vec3d& domainPoint3d, cvf::Vec2d* contourMapPoint, double* valueAtPoint ) const
{
CVF_TIGHT_ASSERT( contourMapPoint );
CVF_TIGHT_ASSERT( valueAtPoint );
cvf::Vec3d mapPos3d = localPoint3d - m_expandedBoundingBox.min() + m_gridBoundingBox.min();
cvf::Vec3d mapPos3d = domainPoint3d - m_expandedBoundingBox.min();
cvf::Vec2d mapPos2d( mapPos3d.x(), mapPos3d.y() );
cvf::Vec2d gridorigin( m_expandedBoundingBox.min().x(), m_expandedBoundingBox.min().y() );

View File

@@ -113,7 +113,7 @@ public:
uint numberOfValidCells() const;
size_t numberOfVertices() const;
bool checkForMapIntersection( const cvf::Vec3d& localPoint3d, cvf::Vec2d* contourMapPoint, double* valueAtPoint ) const;
bool checkForMapIntersection( const cvf::Vec3d& domainPoint3d, cvf::Vec2d* contourMapPoint, double* valueAtPoint ) const;
void setPickPoint( cvf::Vec2d globalPickPoint );
cvf::Vec3d origin3d() const;