mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 23:20:29 -05:00
#12276 Add RFT correlation report plot with cross-plot and tornado plot
* Fix defensive guards and TVD interpolation Guard against out-of-bounds IJK and invalid cells in RifReaderRftInterface. Guard against null eclCase in RimDataSourceForRftPlt::address. Guard against null plot widgets in RiuMultiPlotPage. Fix interpolateMdFromTvd corrupting valid entries after infinity TVD values by skipping infinity entries in the first pass and tracking only the last two valid MD values for the startMD adjustment. * Add RiuQwtCurveSelectorFilter for click-to-select realization in Qwt plots New shared event filter class that installs on a QwtPlot canvas and calls a user-supplied callback with the closest data point on each click. Migrate the local CurveSelectorFilter in RimParameterResultCrossPlot to use the new shared class. Add Z_HIGHLIGHTED_CURVE to ZIndex enum and replace all raw z-order integers in RiuQwtPlotCurveDefines with named constants. * Add RFT correlation report plot with cross-plot and tornado plot New classes: - RimRftCorrelationReportPlot: composite plot showing an RFT well log track alongside a parameter cross-plot and a tornado plot sub-plot. - RimParameterRftCrossPlot: cross-plot of ensemble parameters vs RFT-derived measured depth values, with click-to-select realization support. - RimRftTornadoPlot: tornado plot with correlation-sorted parameter list and click-to-select realization support. - RicCreateRftCorrelationReportFeature: context menu command on RimWellRftPlot that creates a RimRftCorrelationReportPlot in the correlation plot collection. Wire up in RimCorrelationPlotCollection and RimContextCommandBuilder. * Add click-to-select and highlight selected realization in RFT plots Install RiuQwtCurveSelectorFilter on RimWellRftPlot canvas to support click-to-select realization. Highlight the selected realization using a contrast color (orange-red) and increased line thickness. React to both click-to-select in the plot and selection changes in the Data Sources panel. Add Z_HIGHLIGHTED_CURVE z-order and replace raw z-order integers with named constants in RimWellRftPlot. Highlight selected realization with XCROSS symbol in RimParameterRftCrossPlot via RimSummaryEnsembleTools::findSummaryCase. * RimWellRftPlot: add Create RFT Correlation Report to canvas right-click menu Override appendMenuItems in RimWellRftPlot to add RicCreateRftCorrelationReportFeature. Call appendMenuItems from RiuMultiPlotPage::contextMenuEvent so any plot type can contribute canvas menu items without modifying RiuMultiPlotPage. * RicShowPlotDataFeature: support RimRftCorrelationReportPlot Add RimRftCorrelationReportPlot to the isCommandEnabled check and expand it into its cross-plot and tornado sub-plots in onActionTriggered, matching the pattern used for RimCorrelationReportPlot.
This commit is contained in:
1 parent
6d8092cd94
commit
387b19ef62
29 files changed
+2842
-100
No files matched your search
@@ -90,6 +90,7 @@ set(SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuPlotMainWindowTools.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/Riu3DMainWindowTools.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuDockWidgetTools.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuQwtCurveSelectorFilter.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotItemGroup.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotTools.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuDepthQwtPlot.h
|
||||
@@ -204,6 +205,7 @@ set(SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuPlotMainWindowTools.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/Riu3DMainWindowTools.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuDockWidgetTools.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuQwtCurveSelectorFilter.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotItemGroup.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotTools.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiuDepthQwtPlot.cpp
|
||||
|
||||
@@ -364,7 +364,7 @@ void RiuMultiPlotPage::updateSubTitles()
|
||||
{
|
||||
for ( int i = 0; i < m_plotWidgets.size(); ++i )
|
||||
{
|
||||
if ( m_plotWidgets[i]->isChecked() )
|
||||
if ( m_plotWidgets[i] && m_plotWidgets[i]->isChecked() )
|
||||
{
|
||||
m_subTitles[i]->setText( m_plotWidgets[i]->plotTitle() );
|
||||
}
|
||||
@@ -436,6 +436,11 @@ void RiuMultiPlotPage::contextMenuEvent( QContextMenuEvent* event )
|
||||
menuBuilder << "RicShowContributingWellsFromPlotFeature";
|
||||
menuBuilder << "RicNewDefaultSummaryPlotFeature";
|
||||
|
||||
if ( auto* pdmObject = dynamic_cast<caf::PdmUiObjectHandle*>( ownerPlotDefinition() ) )
|
||||
{
|
||||
pdmObject->appendMenuItems( menuBuilder );
|
||||
}
|
||||
|
||||
menuBuilder.appendToMenu( &menu );
|
||||
|
||||
if ( !menu.actions().empty() )
|
||||
@@ -980,7 +985,7 @@ QList<QPointer<RiuQwtPlotLegend>> RiuMultiPlotPage::legendsForVisiblePlots() con
|
||||
QList<QPointer<RiuQwtPlotLegend>> legends;
|
||||
for ( int i = 0; i < m_plotWidgets.size(); ++i )
|
||||
{
|
||||
if ( m_plotWidgets[i]->isChecked() )
|
||||
if ( m_plotWidgets[i] && m_plotWidgets[i]->isChecked() )
|
||||
{
|
||||
legends.push_back( m_legends[i] );
|
||||
}
|
||||
@@ -996,7 +1001,7 @@ QList<QPointer<RiuDraggableOverlayFrame>> RiuMultiPlotPage::legendFramesForVisib
|
||||
QList<QPointer<RiuDraggableOverlayFrame>> legendFrames;
|
||||
for ( int i = 0; i < m_plotWidgets.size(); ++i )
|
||||
{
|
||||
if ( m_plotWidgets[i]->isChecked() )
|
||||
if ( m_plotWidgets[i] && m_plotWidgets[i]->isChecked() )
|
||||
{
|
||||
legendFrames.push_back( m_legendFrames[i] );
|
||||
}
|
||||
@@ -1012,7 +1017,7 @@ QList<QPointer<QLabel>> RiuMultiPlotPage::subTitlesForVisiblePlots() const
|
||||
QList<QPointer<QLabel>> subTitles;
|
||||
for ( int i = 0; i < m_plotWidgets.size(); ++i )
|
||||
{
|
||||
if ( m_plotWidgets[i]->isChecked() )
|
||||
if ( m_plotWidgets[i] && m_plotWidgets[i]->isChecked() )
|
||||
{
|
||||
m_subTitles[i]->setText( m_plotWidgets[i]->plotTitle() );
|
||||
subTitles.push_back( m_subTitles[i] );
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2026 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 "RiuQwtCurveSelectorFilter.h"
|
||||
|
||||
#include "RiuDockWidgetTools.h"
|
||||
|
||||
#include "qwt_plot.h"
|
||||
#include "qwt_scale_map.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
|
||||
#include <limits>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuQwtCurveSelectorFilter::RiuQwtCurveSelectorFilter( QwtPlot* plot, ItemFinder finder )
|
||||
: QObject( plot->canvas() )
|
||||
, m_finder( std::move( finder ) )
|
||||
{
|
||||
plot->canvas()->installEventFilter( this );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RiuQwtCurveSelectorFilter::closestPointIndex( QwtPlot* plot, const QPoint& canvasPos, const std::vector<std::pair<double, double>>& points )
|
||||
{
|
||||
auto xMap = plot->canvasMap( QwtAxis::XBottom );
|
||||
auto yMap = plot->canvasMap( QwtAxis::YLeft );
|
||||
|
||||
const double xRange = std::abs( xMap.s2() - xMap.s1() );
|
||||
const double yRange = std::abs( yMap.s2() - yMap.s1() );
|
||||
const double minRangeEpsilon = 1e-14;
|
||||
if ( xRange < minRangeEpsilon || yRange < minRangeEpsilon ) return -1;
|
||||
|
||||
const double clickX = xMap.invTransform( canvasPos.x() );
|
||||
const double clickY = yMap.invTransform( canvasPos.y() );
|
||||
|
||||
double minDist = std::numeric_limits<double>::max();
|
||||
int closestIdx = -1;
|
||||
for ( int i = 0; i < static_cast<int>( points.size() ); ++i )
|
||||
{
|
||||
const double dx = ( points[i].first - clickX ) / xRange;
|
||||
const double dy = ( points[i].second - clickY ) / yRange;
|
||||
const double dist = dx * dx + dy * dy;
|
||||
if ( dist < minDist )
|
||||
{
|
||||
minDist = dist;
|
||||
closestIdx = i;
|
||||
}
|
||||
}
|
||||
return ( closestIdx >= 0 && minDist < 0.03 * 0.03 ) ? closestIdx : -1;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiuQwtCurveSelectorFilter::eventFilter( QObject* /*watched*/, QEvent* event )
|
||||
{
|
||||
if ( event->type() == QEvent::MouseButtonPress )
|
||||
{
|
||||
auto* mouseEvent = static_cast<QMouseEvent*>( event );
|
||||
if ( mouseEvent->button() == Qt::LeftButton )
|
||||
{
|
||||
if ( const caf::PdmUiItem* item = m_finder( mouseEvent->pos() ) )
|
||||
{
|
||||
RiuDockWidgetTools::selectItemsInTreeView( RiuDockWidgetTools::plotMainWindowDataSourceTreeName(), { item } );
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2026 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 <QObject>
|
||||
|
||||
#include <functional>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
class QPoint;
|
||||
class QwtPlot;
|
||||
|
||||
namespace caf
|
||||
{
|
||||
class PdmUiItem;
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
/// Event filter that selects a realization in the plot main window tree when the user left-clicks
|
||||
/// near a curve on a Qwt plot canvas.
|
||||
///
|
||||
/// The caller supplies a finder callback: given a canvas pixel position, return the PdmUiItem
|
||||
/// (typically a RimSummaryCase*) closest to that position, or nullptr if nothing is close enough.
|
||||
/// When the callback returns a non-null item it is selected via RiuDockWidgetTools.
|
||||
//==================================================================================================
|
||||
class RiuQwtCurveSelectorFilter : public QObject
|
||||
{
|
||||
public:
|
||||
using ItemFinder = std::function<const caf::PdmUiItem*( const QPoint& )>;
|
||||
|
||||
RiuQwtCurveSelectorFilter( QwtPlot* plot, ItemFinder finder );
|
||||
|
||||
// Returns the index of the point in `points` closest to `canvasPos` using axis-normalised
|
||||
// squared distance, or -1 if none falls within the 3% threshold.
|
||||
static int closestPointIndex( QwtPlot* plot, const QPoint& canvasPos, const std::vector<std::pair<double, double>>& points );
|
||||
|
||||
protected:
|
||||
bool eventFilter( QObject* watched, QEvent* event ) override;
|
||||
|
||||
private:
|
||||
ItemFinder m_finder;
|
||||
};
|
||||
@@ -67,6 +67,9 @@ int RiuQwtPlotCurveDefines::zDepthForIndex( ZIndex index )
|
||||
case RiuQwtPlotCurveDefines::ZIndex::Z_SINGLE_CURVE_OBSERVED:
|
||||
return 500;
|
||||
break;
|
||||
case RiuQwtPlotCurveDefines::ZIndex::Z_HIGHLIGHTED_CURVE:
|
||||
return 550;
|
||||
break;
|
||||
case RiuQwtPlotCurveDefines::ZIndex::Z_PLOT_RECT_ANNOTATION:
|
||||
return 600;
|
||||
break;
|
||||
|
||||
@@ -46,6 +46,7 @@ enum class ZIndex
|
||||
Z_SINGLE_CURVE_NON_OBSERVED,
|
||||
Z_ERROR_BARS,
|
||||
Z_SINGLE_CURVE_OBSERVED,
|
||||
Z_HIGHLIGHTED_CURVE,
|
||||
Z_PLOT_RECT_ANNOTATION,
|
||||
Z_REGRESSION_CURVE,
|
||||
Z_ANNOTATION
|
||||
|
||||
Reference in new issue
Block a user