mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Correlation Report Plot
This commit is contained in:
@@ -0,0 +1,296 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020 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 "RimCorrelationReportPlot.h"
|
||||
|
||||
#include "RiaSummaryCurveDefinition.h"
|
||||
|
||||
#include "RimCorrelationMatrixPlot.h"
|
||||
#include "RimParameterResultCrossPlot.h"
|
||||
|
||||
#include "RiuMultiPlotPage.h"
|
||||
|
||||
#include "cafAssert.h"
|
||||
#include "cafPdmUiOrdering.h"
|
||||
#include "cafPdmUiTreeOrdering.h"
|
||||
|
||||
#include <QImage>
|
||||
#include <QPixmap>
|
||||
#include <QStringList>
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
CAF_PDM_SOURCE_INIT( RimCorrelationReportPlot, "CorrelationReportPlot" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimCorrelationReportPlot::RimCorrelationReportPlot()
|
||||
{
|
||||
CAF_PDM_InitObject( "Correlation Report Plot", ":/CorrelationPlot16x16.png", "", "" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_plotWindowTitle, "PlotWindowTitle", "Title", "", "", "" );
|
||||
m_plotWindowTitle.registerGetMethod( this, &RimCorrelationReportPlot::createPlotWindowTitle );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_correlationMatrixPlot, "MatrixPlot", "Matrix Plot", "", "", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_correlationPlot, "CorrelationPlot", "Correlation Plot", "", "", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_parameterResultCrossPlot, "CrossPlot", "Cross Plot", "", "", "" );
|
||||
|
||||
setAsPlotMdiWindow();
|
||||
|
||||
m_showWindow = true;
|
||||
m_correlationMatrixPlot = new RimCorrelationMatrixPlot;
|
||||
m_correlationMatrixPlot->setColSpan( RimPlot::TWO );
|
||||
m_correlationMatrixPlot->setRowSpan( RimPlot::TWO );
|
||||
m_correlationPlot = new RimCorrelationPlot;
|
||||
m_parameterResultCrossPlot = new RimParameterResultCrossPlot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimCorrelationReportPlot::~RimCorrelationReportPlot()
|
||||
{
|
||||
removeMdiWindowFromMdiArea();
|
||||
cleanupBeforeClose();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWidget* RimCorrelationReportPlot::viewWidget()
|
||||
{
|
||||
return m_viewer;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimCorrelationReportPlot::description() const
|
||||
{
|
||||
return m_plotWindowTitle();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QImage RimCorrelationReportPlot::snapshotWindowContent()
|
||||
{
|
||||
QImage image;
|
||||
|
||||
if ( m_viewer )
|
||||
{
|
||||
QPixmap pix( m_viewer->size() );
|
||||
m_viewer->renderTo( &pix );
|
||||
image = pix.toImage();
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCorrelationReportPlot::zoomAll()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* RimCorrelationReportPlot::userDescriptionField()
|
||||
{
|
||||
return &m_plotWindowTitle;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimCorrelationMatrixPlot* RimCorrelationReportPlot::matrixPlot() const
|
||||
{
|
||||
return m_correlationMatrixPlot();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimCorrelationPlot* RimCorrelationReportPlot::correlationPlot() const
|
||||
{
|
||||
return m_correlationPlot();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimParameterResultCrossPlot* RimCorrelationReportPlot::crossPlot() const
|
||||
{
|
||||
return m_parameterResultCrossPlot();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RimCorrelationReportPlot::columnCount() const
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimCorrelationReportPlot::createPlotWindowTitle() const
|
||||
{
|
||||
QStringList ensembles;
|
||||
for ( auto entry : m_correlationMatrixPlot->curveDefinitions() )
|
||||
{
|
||||
if ( entry.ensemble() )
|
||||
{
|
||||
ensembles.push_back( entry.ensemble()->uiName() );
|
||||
}
|
||||
}
|
||||
ensembles.removeDuplicates();
|
||||
QString ensembleNames = ensembles.join( ", " );
|
||||
QString timeStep = m_correlationMatrixPlot->timeStep().toString( Qt::ISODate );
|
||||
|
||||
return QString( "Correlation Report for %1 at %2" ).arg( ensembleNames ).arg( timeStep );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCorrelationReportPlot::recreatePlotWidgets()
|
||||
{
|
||||
CAF_ASSERT( m_viewer );
|
||||
m_correlationMatrixPlot->createPlotWidget();
|
||||
m_correlationPlot->createPlotWidget();
|
||||
m_parameterResultCrossPlot->createPlotWidget();
|
||||
|
||||
m_viewer->addPlot( m_correlationMatrixPlot->viewer() );
|
||||
m_viewer->addPlot( m_correlationPlot->viewer() );
|
||||
m_viewer->addPlot( m_parameterResultCrossPlot->viewer() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCorrelationReportPlot::cleanupBeforeClose()
|
||||
{
|
||||
m_correlationMatrixPlot->detachAllCurves();
|
||||
m_correlationPlot->detachAllCurves();
|
||||
m_parameterResultCrossPlot->detachAllCurves();
|
||||
|
||||
if ( m_viewer )
|
||||
{
|
||||
m_viewer->setParent( nullptr );
|
||||
delete m_viewer;
|
||||
m_viewer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCorrelationReportPlot::doRenderWindowContent( QPaintDevice* paintDevice )
|
||||
{
|
||||
if ( m_viewer )
|
||||
{
|
||||
m_viewer->renderTo( paintDevice );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWidget* RimCorrelationReportPlot::createViewWidget( QWidget* mainWindowParent /*= nullptr */ )
|
||||
{
|
||||
m_viewer = new RiuMultiPlotPage( this, mainWindowParent );
|
||||
m_viewer->setPlotTitle( m_plotWindowTitle() );
|
||||
m_viewer->setSubTitlesVisible( true );
|
||||
recreatePlotWidgets();
|
||||
|
||||
return m_viewer;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCorrelationReportPlot::deleteViewWidget()
|
||||
{
|
||||
cleanupBeforeClose();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCorrelationReportPlot::onLoadDataAndUpdate()
|
||||
{
|
||||
updateMdiWindowVisibility();
|
||||
if ( m_showWindow )
|
||||
{
|
||||
// auto curveDefs = m_correlationMatrixPlot->curveDefinitions();
|
||||
// m_correlationPlot->setCurveDefinitions( curveDefs );
|
||||
// m_parameterResultCrossPlot->setCurveDefinitions( curveDefs );
|
||||
|
||||
m_correlationPlot->setCorrelationFactor( m_correlationMatrixPlot->correlationFactor() );
|
||||
m_correlationPlot->setShowAbsoluteValues( m_correlationMatrixPlot->showAbsoluteValues() );
|
||||
m_correlationPlot->setSortByAbsoluteValues( m_correlationMatrixPlot->sortByAbsoluteValues() );
|
||||
|
||||
m_correlationMatrixPlot->loadDataAndUpdate();
|
||||
m_correlationPlot->loadDataAndUpdate();
|
||||
m_parameterResultCrossPlot->loadDataAndUpdate();
|
||||
}
|
||||
updateLayout();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCorrelationReportPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
||||
{
|
||||
m_correlationMatrixPlot->uiOrdering( "report", uiOrdering );
|
||||
uiOrdering.skipRemainingFields( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCorrelationReportPlot::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering,
|
||||
QString uiConfigName /*= "" */ )
|
||||
{
|
||||
uiTreeOrdering.skipRemainingChildren( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCorrelationReportPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue )
|
||||
{
|
||||
this->loadDataAndUpdate();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCorrelationReportPlot::childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField )
|
||||
{
|
||||
this->loadDataAndUpdate();
|
||||
}
|
||||
Reference in New Issue
Block a user