Files
ResInsight/ApplicationLibCode/ProjectDataModel/Flow/RimWellRftPlot.h
T
Magne Sjaastad 387b19ef62 #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.
2026-04-16 16:45:44 +02:00

208 lines
7.8 KiB
C++

/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil 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 "RimWellLogPlot.h"
#include "RifDataSourceForRftPltQMetaType.h"
#include "cafSelectionChangedReceiver.h"
#include "RiuPlotCurveSymbol.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmPointer.h"
#include "cafPdmPtrField.h"
#include <QMetaObject>
#include <QPointer>
#include <map>
#include <set>
#include <utility>
#include <variant>
class RimEclipseCase;
class RimEclipseResultCase;
class RimRegularLegendConfig;
class RimWellLogCurve;
class RimWellLogChannel;
class RimWellPath;
class RimWellPathCollection;
class RiuWellRftPlot;
class RigEclipseCaseData;
class RiaRftPltCurveDefinition;
class RifDataSourceForRftPlt;
class RifEclipseRftAddress;
class RiuDraggableOverlayFrame;
class RimDataSourceForRftPlt;
class RimSummaryCase;
class RiuPlotCurve;
class RiuPlotItem;
class RimWellRftEnsembleCurveSet;
namespace cvf
{
class Color3f;
}
namespace caf
{
class PdmOptionItemInfo;
}
//==================================================================================================
///
///
//==================================================================================================
class RimWellRftPlot : public RimWellLogPlot, public caf::SelectionChangedReceiver
{
CAF_PDM_HEADER_INIT;
static const std::set<QString> PRESSURE_DATA_NAMES;
static const char PLOT_NAME_QFORMAT_STRING[];
public:
RimWellRftPlot();
~RimWellRftPlot() override;
const QString& simWellOrWellPathName() const;
void setSimWellOrWellPathName( const QString& currWellName );
int branchIndex() const;
std::variant<RimSummaryCase*, RimSummaryEnsemble*> dataSource() const;
static const char* plotNameFormatString();
void deleteCurvesAssosicatedWithObservedData( const RimObservedFmuRftData* observedFmuRftData );
bool showErrorBarsForObservedData() const;
void onLegendDefinitionChanged();
RimWellRftEnsembleCurveSet* findEnsembleCurveSet( RimSummaryEnsemble* ensemble ) const;
void rebuildCurves();
void initializeDataSources( RimWellRftPlot* source );
std::vector<QDateTime> selectedTimeSteps() const;
void setSelectedTimeSteps( const std::vector<QDateTime>& timeSteps );
// Called by owning composite plots before the underlying QwtPlot is destroyed
// so that legend curve raw pointers are cleaned up before QwtPlot auto-deletes them.
void cleanupLegendCurves();
std::vector<RimSummaryEnsemble*> selectedEnsembles() const;
void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override;
private:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName ) override;
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
QList<caf::PdmOptionItemInfo> calculateValueOptionsForSources() const;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void onLoadDataAndUpdate() override;
void setupBeforeSave() override;
void initAfterRead() override;
bool useUndoRedoForFieldChanged() override;
void deleteViewWidget() override;
std::map<QString, QStringList> findWellSources();
void updateEditorsFromPreviousSelection();
void setSelectedSourcesFromCurves();
void syncCurvesFromUiSelection();
void assignWellPathToExtractionCurves();
void syncSourcesIoFieldFromGuiField();
RimObservedFmuRftData* findObservedFmuData( const QString& wellPathName, const QDateTime& timeStep ) const;
std::set<RiaRftPltCurveDefinition> selectedCurveDefs() const;
std::set<RiaRftPltCurveDefinition> curveDefsFromCurves() const;
void setOrInitializeDataSources( const std::vector<RifDataSourceForRftPlt>& sourcesToSelect );
void updateCurvesInPlot( const std::set<RiaRftPltCurveDefinition>& allCurveDefs,
const std::set<RiaRftPltCurveDefinition>& curveDefsToAdd,
const std::set<RimWellLogCurve*>& curvesToDelete );
std::vector<RifDataSourceForRftPlt> selectedSourcesExpanded() const;
// RimViewWindow overrides
void applyCurveAppearance( RimWellLogCurve* curve );
void applyCurveColor( RimWellLogCurve* curve );
void onSelectionManagerSelectionChanged( const std::set<int>& changedSelectionLevels ) override;
RimWellRftEnsembleCurveSet* selectedEnsembleCurveSet() const;
void onLegendItemClicked( std::shared_ptr<RiuPlotItem> plotItem, bool toggle, int sampleIndex );
RimSummaryCase* findClosestRealization( const QPoint& canvasPos );
void highlightSelectedRealization();
void updateFormationsOnPlot() const;
QString associatedSimWellName() const;
static RiuPlotCurveSymbol::PointSymbolEnum statisticsCurveSymbolFromAddress( const RifEclipseRftAddress& address );
static RiuPlotCurveSymbol::LabelPosition statisticsLabelPosFromAddress( const RifEclipseRftAddress& address );
cvf::Color3f findCurveColor( RimWellLogCurve* curve );
void defineCurveColorsAndSymbols( const std::set<RiaRftPltCurveDefinition>& allCurveDefs );
void createEnsembleCurveSets();
void detachAndDeleteLegendCurves();
private:
friend class RimWellRftEnsembleCurveSet;
caf::PdmField<QString> m_wellPathNameOrSimWellName;
caf::PdmField<int> m_branchIndex;
caf::PdmField<bool> m_branchDetection;
caf::PdmField<bool> m_showStatisticsCurves;
caf::PdmField<bool> m_showEnsembleCurves;
caf::PdmField<bool> m_showErrorInObservedData;
caf::PdmField<std::vector<RifDataSourceForRftPlt>> m_selectedSources;
caf::PdmChildArrayField<RimDataSourceForRftPlt*> m_selectedSourcesForIo;
caf::PdmField<std::vector<QDateTime>> m_selectedTimeSteps;
caf::PdmChildArrayField<RimWellRftEnsembleCurveSet*> m_ensembleCurveSets;
caf::PdmPtrField<RimEclipseCase*> m_ensembleCurveSetEclipseCase;
std::map<RimWellRftEnsembleCurveSet*, QPointer<RiuDraggableOverlayFrame>> m_ensembleLegendFrames;
std::map<RifDataSourceForRftPlt, cvf::Color3f> m_dataSourceColors;
std::map<QDateTime, RiuPlotCurveSymbol::PointSymbolEnum> m_timeStepSymbols;
bool m_isOnLoad;
std::vector<RiuPlotCurve*> m_legendPlotCurves;
std::map<RiuPlotCurve*, RimWellRftEnsembleCurveSet*> m_legendCurveToEnsembleCurveSet;
QMetaObject::Connection m_legendClickedConnection;
RimWellRftEnsembleCurveSet* m_highlightedCurveSet = nullptr;
caf::PdmPointer<RimSummaryCase> m_selectedRealization;
caf::PdmChildField<RimWellLogPlot*> m_wellLogPlot_OBSOLETE;
bool m_isInitialized = false;
};