Correlation Report Plot

This commit is contained in:
Gaute Lindkvist
2020-04-29 08:11:30 +02:00
parent dfaf595551
commit 8be36be06b
17 changed files with 711 additions and 29 deletions

View File

@@ -47,6 +47,7 @@
#include "RimCommandObject.h"
#include "RimCorrelationPlot.h"
#include "RimCorrelationPlotCollection.h"
#include "RimCorrelationReportPlot.h"
#include "RimEclipseCaseCollection.h"
#include "RimEclipseView.h"
#include "RimFlowPlotCollection.h"
@@ -333,7 +334,7 @@ bool RiaApplication::openFile( const QString& fileName )
}
else if ( int( fileType ) & int( RiaDefines::ImportFileType::ANY_ECLIPSE_FILE ) )
{
loadingSucceded = RicImportGeneralDataFeature::openEclipseFilesFromFileNames( QStringList{fileName}, true );
loadingSucceded = RicImportGeneralDataFeature::openEclipseFilesFromFileNames( QStringList{ fileName }, true );
lastUsedDialogTag = RiaDefines::defaultDirectoryLabel( fileType );
}
@@ -1609,7 +1610,7 @@ void RiaApplication::loadAndUpdatePlotData()
plotCount += gcpColl ? gcpColl->gridCrossPlots().size() : 0;
plotCount += sppColl ? sppColl->plots().size() : 0;
plotCount += alsColl ? alsColl->plots().size() : 0;
plotCount += corrColl ? corrColl->plots().size() : 0;
plotCount += corrColl ? corrColl->plots().size() + corrColl->reports().size() : 0;
plotCount += gpwColl ? gpwColl->multiPlots().size() : 0;
if ( plotCount > 0 )
@@ -1701,6 +1702,11 @@ void RiaApplication::loadAndUpdatePlotData()
corrPlot->loadDataAndUpdate();
plotProgress.incrementProgress();
}
for ( const auto& reports : corrColl->reports() )
{
reports->loadDataAndUpdate();
plotProgress.incrementProgress();
}
}
if ( gpwColl )
@@ -1824,7 +1830,7 @@ bool RiaApplication::generateCode( const QString& fileName, QString* errMsg )
std::vector<std::shared_ptr<const caf::PdmObject>> commandObjects;
QStringList excludedClassNames{"TestCommand1", "TC2"}; // See RifCommandCore-Text.cpp
QStringList excludedClassNames{ "TestCommand1", "TC2" }; // See RifCommandCore-Text.cpp
auto allObjects = caf::PdmMarkdownBuilder::createAllObjects( caf::PdmDefaultObjectFactory::instance() );
for ( auto classObject : allObjects )

View File

@@ -1,6 +1,7 @@
set (SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicNewCorrelationPlotFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewCorrelationReportPlotFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewCorrelationMatrixPlotFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewParameterResultCrossPlotFeature.h
)
@@ -9,6 +10,7 @@ set (SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicNewCorrelationPlotFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewCorrelationMatrixPlotFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewParameterResultCrossPlotFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewCorrelationReportPlotFeature.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@@ -0,0 +1,81 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicNewCorrelationReportPlotFeature.h"
#include "RimCorrelationPlotCollection.h"
#include "RimCorrelationReportPlot.h"
#include "RiuPlotMainWindowTools.h"
#include "cafSelectionManager.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicNewCorrelationReportPlotFeature, "RicNewCorrelationReportPlotFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewCorrelationReportPlotFeature::isCommandEnabled()
{
RimCorrelationPlotCollection* correlationPlotColl = nullptr;
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( selObj )
{
selObj->firstAncestorOrThisOfType( correlationPlotColl );
}
if ( correlationPlotColl ) return true;
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewCorrelationReportPlotFeature::onActionTriggered( bool isChecked )
{
RimCorrelationPlotCollection* correlationPlotColl = nullptr;
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>( caf::SelectionManager::instance()->selectedItem() );
if ( selObj )
{
selObj->firstAncestorOrThisOfType( correlationPlotColl );
}
if ( !correlationPlotColl ) return;
auto newPlot = correlationPlotColl->createCorrelationReportPlot();
newPlot->loadDataAndUpdate();
correlationPlotColl->updateConnectedEditors();
RiuPlotMainWindowTools::setExpanded( newPlot );
RiuPlotMainWindowTools::selectAsCurrentItem( newPlot );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewCorrelationReportPlotFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "New Correlation Report Plot" );
actionToSetup->setIcon( QIcon( ":/AnalysisPlot16x16.png" ) );
}

View File

@@ -0,0 +1,35 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafCmdFeature.h"
//==================================================================================================
///
//==================================================================================================
class RicNewCorrelationReportPlotFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -5,6 +5,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimCorrelationPlot.h
${CMAKE_CURRENT_LIST_DIR}/RimCorrelationMatrixPlot.h
${CMAKE_CURRENT_LIST_DIR}/RimParameterResultCrossPlot.h
${CMAKE_CURRENT_LIST_DIR}/RimCorrelationPlotCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimCorrelationReportPlot.h
)
set (SOURCE_GROUP_SOURCE_FILES
@@ -13,6 +14,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimCorrelationPlot.cpp
${CMAKE_CURRENT_LIST_DIR}/RimCorrelationMatrixPlot.cpp
${CMAKE_CURRENT_LIST_DIR}/RimParameterResultCrossPlot.cpp
${CMAKE_CURRENT_LIST_DIR}/RimCorrelationPlotCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimCorrelationReportPlot.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@@ -357,6 +357,14 @@ void RimAbstractCorrelationPlot::detachAllCurves()
if ( m_plotWidget ) m_plotWidget->detachItems();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QDateTime RimAbstractCorrelationPlot::timeStep() const
{
return m_timeStep();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -41,8 +41,12 @@ public:
~RimAbstractCorrelationPlot() override;
public:
std::vector<RiaSummaryCurveDefinition> curveDefinitions() const;
void setCurveDefinitions( const std::vector<RiaSummaryCurveDefinition>& curveDefinitions );
std::set<RimSummaryCaseCollection*> ensembles();
RiuQwtPlotWidget* viewer() override;
void detachAllCurves() override;
QDateTime timeStep() const;
protected:
// Overridden PDM methods
@@ -56,9 +60,8 @@ protected:
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) override;
std::set<time_t> allAvailableTimeSteps();
std::vector<RiaSummaryCurveDefinition> curveDefinitions() const;
RiaSummaryCurveDefinitionAnalyser* getOrCreateSelectedCurveDefAnalyser();
std::set<time_t> allAvailableTimeSteps();
RiaSummaryCurveDefinitionAnalyser* getOrCreateSelectedCurveDefAnalyser();
std::set<RifEclipseSummaryAddress> addresses();
std::set<EnsembleParameter> ensembleParameters();
@@ -80,9 +83,7 @@ protected:
// RimPlot Overrides
RiuQwtPlotWidget* doCreatePlotViewWidget( QWidget* mainWindowParent = nullptr ) override;
RiuQwtPlotWidget* viewer() override;
void detachAllCurves() override;
void reattachAllCurves() override {}
void doRemoveFromCollection() override {}
void updateZoomInQwt() override {}

View File

@@ -91,17 +91,23 @@ public:
{
if ( RiaCurveDataTools::isValidValue( value, false ) )
{
m_correlationSum += value * value;
m_correlationSum += value;
m_correlationMagnitude += value * value;
anyValid = true;
}
}
if ( !anyValid ) m_correlationSum = std::numeric_limits<double>::infinity();
if ( !anyValid )
{
m_correlationSum = std::numeric_limits<double>::infinity();
m_correlationMagnitude = std::numeric_limits<double>::infinity();
}
}
QString m_label;
std::vector<double> m_values;
std::vector<QString> m_entryLabels;
double m_correlationSum;
double m_correlationMagnitude;
};
//--------------------------------------------------------------------------------------------------
@@ -116,6 +122,7 @@ RimCorrelationMatrixPlot::RimCorrelationMatrixPlot()
m_correlationFactor.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() );
CAF_PDM_InitField( &m_showAbsoluteValues, "CorrelationAbsValues", true, "Show Absolute Values", "", "", "" );
CAF_PDM_InitField( &m_sortByValues, "CorrelationSorting", true, "Sort Matrix by Values", "", "", "" );
CAF_PDM_InitField( &m_sortByAbsoluteValues, "CorrelationAbsSorting", true, "Sort by Absolute Values", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_legendConfig, "LegendConfig", "", "", "", "" );
m_legendConfig = new RimRegularLegendConfig();
@@ -129,11 +136,35 @@ RimCorrelationMatrixPlot::RimCorrelationMatrixPlot()
//--------------------------------------------------------------------------------------------------
RimCorrelationMatrixPlot::~RimCorrelationMatrixPlot()
{
removeMdiWindowFromMdiArea();
if ( isMdiWindow() ) removeMdiWindowFromMdiArea();
cleanupBeforeClose();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCorrelationMatrixPlot::CorrelationFactor RimCorrelationMatrixPlot::correlationFactor() const
{
return m_correlationFactor();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimCorrelationMatrixPlot::showAbsoluteValues() const
{
return m_showAbsoluteValues;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimCorrelationMatrixPlot::sortByAbsoluteValues() const
{
return m_sortByAbsoluteValues;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -142,7 +173,8 @@ void RimCorrelationMatrixPlot::fieldChangedByUi( const caf::PdmFieldHandle* chan
const QVariant& newValue )
{
RimAbstractCorrelationPlot::fieldChangedByUi( changedField, oldValue, newValue );
if ( changedField == &m_correlationFactor || changedField == &m_showAbsoluteValues || changedField == &m_sortByValues )
if ( changedField == &m_correlationFactor || changedField == &m_showAbsoluteValues ||
changedField == &m_sortByValues || changedField == &m_sortByAbsoluteValues )
{
this->updateLegend();
this->loadDataAndUpdate();
@@ -159,6 +191,7 @@ void RimCorrelationMatrixPlot::defineUiOrdering( QString uiConfigName, caf::PdmU
correlationGroup->add( &m_correlationFactor );
correlationGroup->add( &m_showAbsoluteValues );
correlationGroup->add( &m_sortByValues );
correlationGroup->add( &m_sortByAbsoluteValues );
caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroup( "Summary Vector" );
m_selectedVarsUiField = selectedVarsText();
@@ -167,12 +200,15 @@ void RimCorrelationMatrixPlot::defineUiOrdering( QString uiConfigName, caf::PdmU
curveDataGroup->add( &m_pushButtonSelectSummaryAddress, { false, 1, 0 } );
curveDataGroup->add( &m_timeStep );
caf::PdmUiGroup* plotGroup = uiOrdering.addNewGroup( "Plot Settings" );
plotGroup->add( &m_showPlotTitle );
plotGroup->add( &m_useAutoPlotTitle );
plotGroup->add( &m_description );
m_description.uiCapability()->setUiReadOnly( m_useAutoPlotTitle() );
RimPlot::defineUiOrdering( uiConfigName, *plotGroup );
if ( uiConfigName != "report" )
{
caf::PdmUiGroup* plotGroup = uiOrdering.addNewGroup( "Plot Settings" );
plotGroup->add( &m_showPlotTitle );
plotGroup->add( &m_useAutoPlotTitle );
plotGroup->add( &m_description );
m_description.uiCapability()->setUiReadOnly( m_useAutoPlotTitle() );
RimPlot::defineUiOrdering( uiConfigName, *plotGroup );
}
uiOrdering.skipRemainingFields( true );
}
@@ -289,12 +325,16 @@ void eraseInvalidEntries( std::vector<CorrelationMatrixRowOrColumn>& matrix )
matrix.end() );
}
void sortEntries( std::vector<CorrelationMatrixRowOrColumn>& matrix )
void sortEntries( std::vector<CorrelationMatrixRowOrColumn>& matrix, bool sortByAbsoluteValues )
{
std::sort( matrix.begin(),
matrix.end(),
[]( const CorrelationMatrixRowOrColumn& lhs, const CorrelationMatrixRowOrColumn& rhs ) {
return lhs.m_correlationSum > rhs.m_correlationSum;
[&sortByAbsoluteValues]( const CorrelationMatrixRowOrColumn& lhs,
const CorrelationMatrixRowOrColumn& rhs ) -> bool {
if ( sortByAbsoluteValues )
return lhs.m_correlationMagnitude > rhs.m_correlationMagnitude;
else
return lhs.m_correlationSum > rhs.m_correlationSum;
} );
}
@@ -413,12 +453,12 @@ void RimCorrelationMatrixPlot::createMatrix()
}
eraseInvalidEntries( correlationMatrixColumns );
if ( m_sortByValues() ) sortEntries( correlationMatrixColumns );
if ( m_sortByValues() ) sortEntries( correlationMatrixColumns, m_sortByAbsoluteValues() );
auto correlationMatrixRows = transpose( correlationMatrixColumns );
eraseInvalidEntries( correlationMatrixRows );
if ( m_sortByValues() ) sortEntries( correlationMatrixRows );
if ( m_sortByValues() ) sortEntries( correlationMatrixRows, m_sortByAbsoluteValues() );
for ( size_t rowIdx = 0u; rowIdx < correlationMatrixRows.size(); ++rowIdx )
{

View File

@@ -43,6 +43,10 @@ public:
RimCorrelationMatrixPlot();
~RimCorrelationMatrixPlot() override;
CorrelationFactor correlationFactor() const;
bool showAbsoluteValues() const;
bool sortByAbsoluteValues() const;
private:
// Overridden PDM methods
@@ -65,9 +69,11 @@ private:
void updateLegend() override;
private:
caf::PdmField<CorrelationFactorEnum> m_correlationFactor;
caf::PdmField<bool> m_showAbsoluteValues;
caf::PdmField<bool> m_sortByValues;
caf::PdmField<CorrelationFactorEnum> m_correlationFactor;
caf::PdmField<bool> m_showAbsoluteValues;
caf::PdmField<bool> m_sortByValues;
caf::PdmField<bool> m_sortByAbsoluteValues;
caf::PdmChildField<RimRegularLegendConfig*> m_legendConfig;
std::map<size_t, QString> m_paramLabels;

View File

@@ -77,7 +77,7 @@ RimCorrelationPlot::RimCorrelationPlot()
//--------------------------------------------------------------------------------------------------
RimCorrelationPlot::~RimCorrelationPlot()
{
removeMdiWindowFromMdiArea();
if ( isMdiWindow() ) removeMdiWindowFromMdiArea();
cleanupBeforeClose();
}
@@ -293,3 +293,51 @@ void RimCorrelationPlot::updatePlotTitle()
m_plotWidget->setPlotTitle( m_description );
m_plotWidget->setPlotTitleEnabled( m_showPlotTitle && isMdiWindow() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCorrelationPlot::CorrelationFactor RimCorrelationPlot::correlationFactor() const
{
return m_correlationFactor();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCorrelationPlot::setCorrelationFactor( CorrelationFactor factor )
{
m_correlationFactor = factor;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimCorrelationPlot::showAbsoluteValues() const
{
m_showAbsoluteValues;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCorrelationPlot::setShowAbsoluteValues( bool showAbsoluteValues )
{
m_showAbsoluteValues = showAbsoluteValues;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimCorrelationPlot::sortByAbsoluteValues() const
{
return m_sortByAbsoluteValues;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCorrelationPlot::setSortByAbsoluteValues( bool sortByAbsoluteValues )
{
m_sortByAbsoluteValues = sortByAbsoluteValues;
}

View File

@@ -46,6 +46,15 @@ public:
RimCorrelationPlot();
~RimCorrelationPlot() override;
CorrelationFactor correlationFactor() const;
void setCorrelationFactor( CorrelationFactor factor );
bool showAbsoluteValues() const;
void setShowAbsoluteValues( bool showAbsoluteValues );
bool sortByAbsoluteValues() const;
void setSortByAbsoluteValues( bool sortByAbsoluteValues );
private:
// Overridden PDM methods

View File

@@ -21,6 +21,7 @@
#include "RiaSummaryCurveDefinition.h"
#include "RimCorrelationMatrixPlot.h"
#include "RimCorrelationPlot.h"
#include "RimCorrelationReportPlot.h"
#include "RimParameterResultCrossPlot.h"
#include "RimProject.h"
@@ -34,7 +35,10 @@ RimCorrelationPlotCollection::RimCorrelationPlotCollection()
CAF_PDM_InitObject( "Correlation Plots", ":/AnalysisPlots16x16.png", "", "" );
CAF_PDM_InitFieldNoDefault( &m_correlationPlots, "CorrelationPlots", "Correlation Plots", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_correlationReports, "CorrelationReports", "Correlation Reports", "", "", "" );
m_correlationPlots.uiCapability()->setUiHidden( true );
m_correlationReports.uiCapability()->setUiHidden( true );
}
//--------------------------------------------------------------------------------------------------
@@ -86,6 +90,20 @@ RimParameterResultCrossPlot* RimCorrelationPlotCollection::createParameterResult
return plot;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCorrelationReportPlot*
RimCorrelationPlotCollection::createCorrelationReportPlot( bool defaultToFirstEnsembleFopt /*= true */ )
{
RimCorrelationReportPlot* report = new RimCorrelationReportPlot;
report->setAsPlotMdiWindow();
if ( defaultToFirstEnsembleFopt ) applyFirstEnsembleFieldAddressesToReport( report, "FOPT" );
m_correlationReports.push_back( report );
return report;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -102,12 +120,21 @@ std::vector<RimAbstractCorrelationPlot*> RimCorrelationPlotCollection::plots()
return m_correlationPlots.childObjects();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimCorrelationReportPlot*> RimCorrelationPlotCollection::reports()
{
return m_correlationReports.childObjects();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCorrelationPlotCollection::deleteAllChildObjects()
{
m_correlationPlots.deleteAllChildObjects();
m_correlationReports.deleteAllChildObjects();
}
//--------------------------------------------------------------------------------------------------
@@ -141,3 +168,35 @@ void RimCorrelationPlotCollection::applyFirstEnsembleFieldAddressesToPlot( RimAb
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimCorrelationPlotCollection::applyFirstEnsembleFieldAddressesToReport( RimCorrelationReportPlot* plot,
const std::string& quantityName /*= "" */ )
{
std::vector<RimSummaryCaseCollection*> ensembles;
RimProject::current()->descendantsIncludingThisOfType( ensembles );
if ( !ensembles.empty() )
{
std::set<RifEclipseSummaryAddress> allAddresses = ensembles.front()->ensembleSummaryAddresses();
std::vector<RiaSummaryCurveDefinition> curveDefsMatrix;
std::vector<RiaSummaryCurveDefinition> curveDefsTornadoAndCrossPlot;
for ( auto address : allAddresses )
{
if ( address.category() == RifEclipseSummaryAddress::SUMMARY_FIELD )
{
curveDefsMatrix.push_back( RiaSummaryCurveDefinition( nullptr, address, ensembles.front() ) );
if ( quantityName.empty() || quantityName == address.quantityName() )
{
curveDefsTornadoAndCrossPlot.push_back(
RiaSummaryCurveDefinition( nullptr, address, ensembles.front() ) );
}
}
}
plot->matrixPlot()->setCurveDefinitions( curveDefsMatrix );
plot->correlationPlot()->setCurveDefinitions( curveDefsTornadoAndCrossPlot );
plot->crossPlot()->setCurveDefinitions( curveDefsTornadoAndCrossPlot );
plot->crossPlot()->setEnsembleParameter( ensembles.front()->alphabeticEnsembleParameters().front().name );
}
}

View File

@@ -24,6 +24,7 @@
class RimAbstractCorrelationPlot;
class RimCorrelationPlot;
class RimCorrelationMatrixPlot;
class RimCorrelationReportPlot;
class RimParameterResultCrossPlot;
//==================================================================================================
@@ -41,15 +42,20 @@ public:
RimCorrelationPlot* createCorrelationPlot( bool defaultToFirstEnsembleFopt = true );
RimCorrelationMatrixPlot* createCorrelationMatrixPlot( bool defaultToFirstEnsembleField = true );
RimParameterResultCrossPlot* createParameterResultCrossPlot( bool defaultToFirstEnsembleFopt = true );
void removePlot( RimAbstractCorrelationPlot* CorrelationPlot );
RimCorrelationReportPlot* createCorrelationReportPlot( bool defaultToFirstEnsembleFopt = true );
void removePlot( RimAbstractCorrelationPlot* correlationPlot );
void removeReport( RimCorrelationReportPlot* correlationReport );
std::vector<RimAbstractCorrelationPlot*> plots();
std::vector<RimCorrelationReportPlot*> reports();
void deleteAllChildObjects();
private:
void applyFirstEnsembleFieldAddressesToPlot( RimAbstractCorrelationPlot* plot, const std::string& quantityName = "" );
void applyFirstEnsembleFieldAddressesToReport( RimCorrelationReportPlot* plot, const std::string& quantityName = "" );
private:
caf::PdmChildArrayField<RimAbstractCorrelationPlot*> m_correlationPlots;
caf::PdmChildArrayField<RimCorrelationReportPlot*> m_correlationReports;
};

View File

@@ -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();
}

View File

@@ -0,0 +1,82 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RimCorrelationPlot.h"
#include "RimPlotWindow.h"
#include "cafPdmChildField.h"
#include "cafPdmProxyValueField.h"
#include "cafPdmPtrField.h"
#include <QDateTime>
#include <QPointer>
class RimAnalysisPlotDataEntry;
class RimCorrelationMatrixPlot;
class RimParameterResultCrossPlot;
class RimSummaryCaseCollection;
class RiuMultiPlotPage;
class RimCorrelationReportPlot : public RimPlotWindow
{
CAF_PDM_HEADER_INIT;
using CorrelationFactor = RimCorrelationPlot::CorrelationFactor;
using CorrelationFactorEnum = RimCorrelationPlot::CorrelationFactorEnum;
public:
RimCorrelationReportPlot();
~RimCorrelationReportPlot() override;
QWidget* viewWidget() override;
QString description() const override;
QImage snapshotWindowContent() override;
void zoomAll() override;
caf::PdmFieldHandle* userDescriptionField() override;
RimCorrelationMatrixPlot* matrixPlot() const;
RimCorrelationPlot* correlationPlot() const;
RimParameterResultCrossPlot* crossPlot() const;
int columnCount() const override;
private:
QString createPlotWindowTitle() const;
void recreatePlotWidgets();
void cleanupBeforeClose();
void doRenderWindowContent( QPaintDevice* paintDevice ) override;
QWidget* createViewWidget( QWidget* mainWindowParent = nullptr ) override;
void deleteViewWidget() override;
void onLoadDataAndUpdate() override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) override;
private:
caf::PdmProxyValueField<QString> m_plotWindowTitle;
caf::PdmChildField<RimCorrelationMatrixPlot*> m_correlationMatrixPlot;
caf::PdmChildField<RimCorrelationPlot*> m_correlationPlot;
caf::PdmChildField<RimParameterResultCrossPlot*> m_parameterResultCrossPlot;
QPointer<RiuMultiPlotPage> m_viewer;
};

View File

@@ -69,7 +69,7 @@ RimParameterResultCrossPlot::RimParameterResultCrossPlot()
//--------------------------------------------------------------------------------------------------
RimParameterResultCrossPlot::~RimParameterResultCrossPlot()
{
removeMdiWindowFromMdiArea();
if ( isMdiWindow() ) removeMdiWindowFromMdiArea();
cleanupBeforeClose();
}

View File

@@ -534,6 +534,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder << "RicNewCorrelationPlotFeature";
menuBuilder << "RicNewCorrelationMatrixPlotFeature";
menuBuilder << "RicNewParameterResultCrossPlotFeature";
menuBuilder << "RicNewCorrelationReportPlotFeature";
}
else if ( dynamic_cast<RimCorrelationPlot*>( firstUiItem ) )
{