Show grid statistics context menu items only when clicking inside overlay info box

This commit is contained in:
Magne Sjaastad committed 2026-06-11 16:29:04 +02:00
1 parent a4246bfebc
commit 7f24637fa7
3 files changed
+22 -3

No files matched your search

@@ -1282,6 +1282,18 @@ cvf::OverlayItem* RiuViewer::pickFixedPositionedLegend( int winPosX, int winPosY
return nullptr;
}
//--------------------------------------------------------------------------------------------------
/// Returns true if the given window position is inside the overlay info box (the result info and
/// grid statistics histogram drawn in the upper left corner of the view).
//--------------------------------------------------------------------------------------------------
bool RiuViewer::isMousePosWithinInfoBox( int winPosX, int winPosY ) const
{
if ( !m_infoPickArea.isNull() && m_infoPickArea.contains( winPosX, winPosY ) ) return true;
if ( !m_infoPickAreaCompView.isNull() && m_infoPickAreaCompView.contains( winPosX, winPosY ) ) return true;
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -127,6 +127,8 @@ public:
cvf::OverlayItem* pickFixedPositionedLegend( int winPosX, int winPosY );
bool isMousePosWithinInfoBox( int winPosX, int winPosY ) const;
void setCursorPosition( const cvf::Vec3d& domainCoord );
std::vector<cvf::ref<cvf::Part>> visibleParts();
@@ -635,9 +635,14 @@ void RiuViewerCommands::displayContextMenu( QMouseEvent* event )
menuBuilder.subMenuEnd();
menuBuilder.addSeparator();
menuBuilder << "RicCreateGridStatisticsPlotFeature";
menuBuilder << "RicShowGridStatisticsFeature";
menuBuilder << "RicCopyGridStatisticsToClipboardFeature";
// Grid statistics commands operate on the result shown in the overlay info box, so only
// offer them when the context menu is invoked inside that box, not on the view geometry.
if ( m_viewer->isMousePosWithinInfoBox( event->x(), event->y() ) )
{
menuBuilder << "RicCreateGridStatisticsPlotFeature";
menuBuilder << "RicShowGridStatisticsFeature";
menuBuilder << "RicCopyGridStatisticsToClipboardFeature";
}
menuBuilder << "RicSelectColorResult";
menuBuilder.addSeparator();
menuBuilder << "RicHideGridGeometryFeature";