mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 23:20:29 -05:00
* 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.
390 lines
13 KiB
C++
390 lines
13 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.
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "RicShowPlotDataFeature.h"
|
|
|
|
#include "RiaFeatureCommandContext.h"
|
|
#include "RiaGuiApplication.h"
|
|
#include "RiaPreferencesSummary.h"
|
|
#include "RiaQDateTimeTools.h"
|
|
|
|
#include "RimAnalysisPlot.h"
|
|
#include "RimCorrelationMatrixPlot.h"
|
|
#include "RimCorrelationPlot.h"
|
|
#include "RimCorrelationReportPlot.h"
|
|
#include "RimGridCrossPlot.h"
|
|
#include "RimGridCrossPlotCurve.h"
|
|
#include "RimParameterResultCrossPlot.h"
|
|
#include "RimParameterRftCrossPlot.h"
|
|
#include "RimPlotWindow.h"
|
|
#include "RimProject.h"
|
|
#include "RimRftCorrelationReportPlot.h"
|
|
#include "RimRftTornadoPlot.h"
|
|
#include "RimSummaryPlot.h"
|
|
#include "RimWellAllocationOverTimePlot.h"
|
|
#include "RimWellLogPlot.h"
|
|
#include "RimWellLogTrack.h"
|
|
|
|
#include "VerticalFlowPerformance/RimCustomVfpPlot.h"
|
|
|
|
#include "RiuPlotMainWindow.h"
|
|
#include "RiuTextDialog.h"
|
|
|
|
#include "cafPdmPointer.h"
|
|
#include "cafProgressInfo.h"
|
|
#include "cafSelectionManagerTools.h"
|
|
|
|
#include <QAction>
|
|
|
|
CAF_CMD_SOURCE_INIT( RicShowPlotDataFeature, "RicShowPlotDataFeature" );
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
/// Private text provider class for summary plots
|
|
//--------------------------------------------------------------------------------------------------
|
|
class RiuTabbedSummaryPlotTextProvider : public RiuTabbedTextProvider
|
|
{
|
|
public:
|
|
RiuTabbedSummaryPlotTextProvider( RimSummaryPlot* summaryPlot )
|
|
: m_summaryPlot( summaryPlot )
|
|
{
|
|
}
|
|
|
|
bool isValid() const override { return m_summaryPlot.notNull(); }
|
|
|
|
QString description() const override
|
|
{
|
|
CVF_ASSERT( m_summaryPlot.notNull() && "Need to check that provider is valid" );
|
|
return m_summaryPlot->description();
|
|
}
|
|
|
|
QString tabTitle( int tabIndex ) const override
|
|
{
|
|
auto allTabs = tabs();
|
|
CVF_ASSERT( tabIndex < (int)allTabs.size() );
|
|
RiaDefines::DateTimePeriod timePeriod = allTabs[tabIndex];
|
|
if ( timePeriod == RiaDefines::DateTimePeriod::NONE )
|
|
{
|
|
return "No Resampling";
|
|
}
|
|
|
|
return QString( "%1" ).arg( RiaQDateTimeTools::dateTimePeriodName( timePeriod ) );
|
|
}
|
|
|
|
QString tabText( int tabIndex ) const override
|
|
{
|
|
CVF_ASSERT( m_summaryPlot.notNull() && "Need to check that provider is valid" );
|
|
|
|
RiaDefines::DateTimePeriod timePeriod = indexToPeriod( tabIndex );
|
|
RiaPreferencesSummary* prefs = RiaPreferencesSummary::current();
|
|
|
|
return m_summaryPlot->asciiDataForSummaryPlotExport( timePeriod, prefs->showSummaryTimeAsLongString() );
|
|
}
|
|
|
|
int tabCount() const override { return (int)tabs().size(); }
|
|
|
|
private:
|
|
static RiaDefines::DateTimePeriod indexToPeriod( int tabIndex )
|
|
{
|
|
auto allTabs = tabs();
|
|
CVF_ASSERT( tabIndex < (int)allTabs.size() );
|
|
RiaDefines::DateTimePeriod timePeriod = allTabs[tabIndex];
|
|
return timePeriod;
|
|
}
|
|
|
|
static std::vector<RiaDefines::DateTimePeriod> tabs()
|
|
{
|
|
std::vector<RiaDefines::DateTimePeriod> dateTimePeriods;
|
|
dateTimePeriods.emplace_back( RiaDefines::DateTimePeriod::NONE );
|
|
dateTimePeriods.emplace_back( RiaDefines::DateTimePeriod::YEAR );
|
|
dateTimePeriods.emplace_back( RiaDefines::DateTimePeriod::HALFYEAR );
|
|
dateTimePeriods.emplace_back( RiaDefines::DateTimePeriod::QUARTER );
|
|
dateTimePeriods.emplace_back( RiaDefines::DateTimePeriod::MONTH );
|
|
dateTimePeriods.emplace_back( RiaDefines::DateTimePeriod::WEEK );
|
|
dateTimePeriods.emplace_back( RiaDefines::DateTimePeriod::DAY );
|
|
dateTimePeriods.emplace_back( RiaDefines::DateTimePeriod::HOUR );
|
|
dateTimePeriods.emplace_back( RiaDefines::DateTimePeriod::MINUTE );
|
|
|
|
return dateTimePeriods;
|
|
}
|
|
|
|
private:
|
|
caf::PdmPointer<RimSummaryPlot> m_summaryPlot;
|
|
};
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
/// Private text provider class for grid cross plots
|
|
//--------------------------------------------------------------------------------------------------
|
|
class RiuTabbedGridCrossPlotTextProvider : public RiuTabbedTextProvider
|
|
{
|
|
public:
|
|
RiuTabbedGridCrossPlotTextProvider( RimGridCrossPlot* crossPlot )
|
|
: m_crossPlot( crossPlot )
|
|
{
|
|
}
|
|
|
|
bool isValid() const override { return m_crossPlot.notNull(); }
|
|
|
|
QString description() const override
|
|
{
|
|
CVF_ASSERT( m_crossPlot.notNull() && "Need to check that provider is valid" );
|
|
return m_crossPlot->createAutoName();
|
|
}
|
|
|
|
QString tabTitle( int tabIndex ) const override
|
|
{
|
|
CVF_ASSERT( m_crossPlot.notNull() && "Need to check that provider is valid" );
|
|
return m_crossPlot->asciiTitleForPlotExport( tabIndex );
|
|
}
|
|
|
|
QString tabText( int tabIndex ) const override
|
|
{
|
|
CVF_ASSERT( m_crossPlot.notNull() && "Need to check that provider is valid" );
|
|
return m_crossPlot->asciiDataForGridCrossPlotExport( tabIndex );
|
|
}
|
|
|
|
int tabCount() const override
|
|
{
|
|
CVF_ASSERT( m_crossPlot.notNull() && "Need to check that provider is valid" );
|
|
return (int)m_crossPlot->dataSets().size();
|
|
}
|
|
|
|
private:
|
|
caf::PdmPointer<RimGridCrossPlot> m_crossPlot;
|
|
};
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
///
|
|
/// RicShowPlotDataFeature
|
|
///
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RicShowPlotDataFeature::isCommandEnabled() const
|
|
{
|
|
QString content = RiaFeatureCommandContext::instance()->contentString();
|
|
if ( !content.isEmpty() )
|
|
{
|
|
return true;
|
|
}
|
|
|
|
std::vector<RimPlotWindow*> selection;
|
|
getSelection( selection );
|
|
|
|
int validPlots = 0;
|
|
|
|
for ( auto plot : selection )
|
|
{
|
|
if ( dynamic_cast<RimSummaryPlot*>( plot ) || dynamic_cast<RimWellLogPlot*>( plot ) || dynamic_cast<RimWellLogTrack*>( plot ) ||
|
|
dynamic_cast<RimGridCrossPlot*>( plot ) || dynamic_cast<RimCustomVfpPlot*>( plot ) ||
|
|
dynamic_cast<RimWellAllocationOverTimePlot*>( plot ) || dynamic_cast<RimAnalysisPlot*>( plot ) ||
|
|
dynamic_cast<RimCorrelationMatrixPlot*>( plot ) || dynamic_cast<RimAbstractCorrelationPlot*>( plot ) ||
|
|
dynamic_cast<RimCorrelationReportPlot*>( plot ) || dynamic_cast<RimRftCorrelationReportPlot*>( plot ) )
|
|
{
|
|
validPlots++;
|
|
}
|
|
}
|
|
return ( validPlots > 0 );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicShowPlotDataFeature::onActionTriggered( bool isChecked )
|
|
{
|
|
QString content = RiaFeatureCommandContext::instance()->contentString();
|
|
if ( !content.isEmpty() )
|
|
{
|
|
QString title = "Data Content";
|
|
{
|
|
QString titleCandidate = RiaFeatureCommandContext::instance()->titleString();
|
|
if ( !titleCandidate.isEmpty() ) title = titleCandidate;
|
|
}
|
|
|
|
RicShowPlotDataFeature::showTextWindow( title, content );
|
|
|
|
return;
|
|
}
|
|
|
|
disableModelChangeContribution();
|
|
|
|
std::vector<RimPlotWindow*> selection;
|
|
getSelection( selection );
|
|
|
|
// Using RiuTabbedSummaryPlotTextProvider
|
|
std::vector<RimSummaryPlot*> summaryPlots;
|
|
|
|
// Using RiuTabbedGridCrossPlotTextProvider
|
|
std::vector<RimGridCrossPlot*> crossPlots;
|
|
|
|
// Special handling for well log plots
|
|
std::vector<RimWellLogPlot*> wellLogPlots;
|
|
|
|
// Show content using RimPlot::description() and RimPlot::asciiDataForPlotExport()
|
|
std::vector<RimPlot*> rimPlots;
|
|
|
|
for ( auto plot : selection )
|
|
{
|
|
if ( auto sumPlot = dynamic_cast<RimSummaryPlot*>( plot ) )
|
|
{
|
|
summaryPlots.push_back( sumPlot );
|
|
continue;
|
|
}
|
|
|
|
if ( auto xPlot = dynamic_cast<RimGridCrossPlot*>( plot ) )
|
|
{
|
|
crossPlots.push_back( xPlot );
|
|
continue;
|
|
}
|
|
|
|
if ( auto wellLogPlot = dynamic_cast<RimWellLogPlot*>( plot ) )
|
|
{
|
|
wellLogPlots.push_back( wellLogPlot );
|
|
continue;
|
|
}
|
|
|
|
if ( auto correlationReportPlot = dynamic_cast<RimCorrelationReportPlot*>( plot ) )
|
|
{
|
|
// A correlation report plot contains three plots. Add them as individual plots to rimPlots to make the data available in three
|
|
// individual text dialogs.
|
|
|
|
rimPlots.push_back( correlationReportPlot->matrixPlot() );
|
|
rimPlots.push_back( correlationReportPlot->correlationPlot() );
|
|
rimPlots.push_back( correlationReportPlot->crossPlot() );
|
|
continue;
|
|
}
|
|
|
|
if ( auto rftReportPlot = dynamic_cast<RimRftCorrelationReportPlot*>( plot ) )
|
|
{
|
|
rimPlots.push_back( rftReportPlot->crossPlot() );
|
|
rimPlots.push_back( rftReportPlot->correlationPlot() );
|
|
continue;
|
|
}
|
|
|
|
if ( auto rimPlot = dynamic_cast<RimPlot*>( plot ) )
|
|
{
|
|
rimPlots.push_back( rimPlot );
|
|
}
|
|
}
|
|
|
|
for ( RimSummaryPlot* summaryPlot : summaryPlots )
|
|
{
|
|
auto textProvider = new RiuTabbedSummaryPlotTextProvider( summaryPlot );
|
|
RicShowPlotDataFeature::showTabbedTextWindow( textProvider );
|
|
}
|
|
for ( RimGridCrossPlot* crossPlot : crossPlots )
|
|
{
|
|
auto textProvider = new RiuTabbedGridCrossPlotTextProvider( crossPlot );
|
|
RicShowPlotDataFeature::showTabbedTextWindow( textProvider );
|
|
}
|
|
|
|
for ( auto rimPlot : rimPlots )
|
|
{
|
|
QString title = rimPlot->description();
|
|
QString text = title;
|
|
text += "\n";
|
|
text += "\n";
|
|
text += rimPlot->asciiDataForPlotExport();
|
|
|
|
RicShowPlotDataFeature::showTextWindow( title, text );
|
|
}
|
|
|
|
for ( auto wellLogPlot : wellLogPlots )
|
|
{
|
|
QString title = wellLogPlot->description();
|
|
QString text = title;
|
|
text += "\n";
|
|
text += "\n";
|
|
text += wellLogPlot->asciiDataForPlotExport();
|
|
|
|
RicShowPlotDataFeature::showTextWindow( title, text );
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicShowPlotDataFeature::setupActionLook( QAction* actionToSetup )
|
|
{
|
|
actionToSetup->setText( "Show Plot Data" );
|
|
actionToSetup->setIcon( QIcon( ":/PlotWindow.svg" ) );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicShowPlotDataFeature::showTabbedTextWindow( RiuTabbedTextProvider* textProvider )
|
|
{
|
|
RiuPlotMainWindow* plotwindow = RiaGuiApplication::instance()->mainPlotWindow();
|
|
CVF_ASSERT( plotwindow );
|
|
|
|
auto* textWidget = new RiuTabbedTextDialog( textProvider );
|
|
textWidget->setMinimumSize( 800, 600 );
|
|
plotwindow->addToTemporaryWidgets( textWidget );
|
|
textWidget->show();
|
|
textWidget->redrawText();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicShowPlotDataFeature::showTextWindow( const QString& title, const QString& text )
|
|
{
|
|
RiuPlotMainWindow* plotwindow = RiaGuiApplication::instance()->mainPlotWindow();
|
|
CVF_ASSERT( plotwindow );
|
|
|
|
auto* textWiget = new RiuTextDialog( RiaGuiApplication::widgetToUseAsParent() );
|
|
textWiget->setMinimumSize( 400, 600 );
|
|
|
|
textWiget->setWindowTitle( title );
|
|
textWiget->setText( text );
|
|
|
|
textWiget->show();
|
|
|
|
plotwindow->addToTemporaryWidgets( textWiget );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicShowPlotDataFeature::getSelection( std::vector<RimPlotWindow*>& selection ) const
|
|
{
|
|
if ( sender() )
|
|
{
|
|
QVariant userData = this->userData();
|
|
if ( !userData.isNull() && userData.canConvert<void*>() )
|
|
{
|
|
auto* plot = static_cast<RimPlot*>( userData.value<void*>() );
|
|
if ( plot ) selection.push_back( plot );
|
|
}
|
|
}
|
|
|
|
if ( selection.empty() )
|
|
{
|
|
auto selectedObjects = caf::selectedObjectsByType<caf::PdmObject*>();
|
|
for ( auto obj : selectedObjects )
|
|
{
|
|
if ( !obj ) continue;
|
|
|
|
if ( auto plotWindow = obj->firstAncestorOrThisOfType<RimPlotWindow>() )
|
|
{
|
|
selection.push_back( plotWindow );
|
|
}
|
|
}
|
|
}
|
|
}
|