mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Show Plot Data missing for some plots
* Add plotContentAsText() to bar chart builder * Add show plot data to analysis plot * Refactor analysis plot * Enable context menu in Analysis Plot * Add show plot data for general RimPlots * Show plot data for correlation report in three separate text dialogs
This commit is contained in:
@@ -33,10 +33,12 @@
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryCaseCollection.h"
|
||||
|
||||
#include "RiuContextMenuLauncher.h"
|
||||
#include "RiuPlotMainWindowTools.h"
|
||||
#include "RiuQwtPlotWidget.h"
|
||||
#include "RiuSummaryVectorSelectionDialog.h"
|
||||
|
||||
#include "cafCmdFeatureMenuBuilder.h"
|
||||
#include "cafPdmUiComboBoxEditor.h"
|
||||
#include "cafPdmUiLineEditor.h"
|
||||
#include "cafPdmUiPushButtonEditor.h"
|
||||
@@ -91,6 +93,8 @@ RimAbstractCorrelationPlot::RimAbstractCorrelationPlot()
|
||||
CAF_PDM_InitField( &m_editCaseFilter, "EditCaseFilter", false, "Edit" );
|
||||
m_editCaseFilter.uiCapability()->setUiEditorTypeName( caf::PdmUiToolButtonEditor::uiEditorTypeName() );
|
||||
m_editCaseFilter.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
|
||||
|
||||
m_analyserOfSelectedCurveDefs = std::make_unique<RiaSummaryCurveDefinitionAnalyser>();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -363,13 +367,8 @@ std::vector<RiaSummaryCurveDefinition> RimAbstractCorrelationPlot::curveDefiniti
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaSummaryCurveDefinitionAnalyser* RimAbstractCorrelationPlot::getOrCreateSelectedCurveDefAnalyser()
|
||||
RiaSummaryCurveDefinitionAnalyser* RimAbstractCorrelationPlot::getOrCreateSelectedCurveDefAnalyser() const
|
||||
{
|
||||
if ( !m_analyserOfSelectedCurveDefs )
|
||||
{
|
||||
m_analyserOfSelectedCurveDefs = std::unique_ptr<RiaSummaryCurveDefinitionAnalyser>( new RiaSummaryCurveDefinitionAnalyser );
|
||||
}
|
||||
|
||||
m_analyserOfSelectedCurveDefs->setCurveDefinitions( curveDefinitions() );
|
||||
return m_analyserOfSelectedCurveDefs.get();
|
||||
}
|
||||
@@ -377,7 +376,7 @@ RiaSummaryCurveDefinitionAnalyser* RimAbstractCorrelationPlot::getOrCreateSelect
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::set<RifEclipseSummaryAddress> RimAbstractCorrelationPlot::addresses()
|
||||
std::set<RifEclipseSummaryAddress> RimAbstractCorrelationPlot::addresses() const
|
||||
{
|
||||
std::set<RifEclipseSummaryAddress> addresses;
|
||||
|
||||
@@ -392,7 +391,7 @@ std::set<RifEclipseSummaryAddress> RimAbstractCorrelationPlot::addresses()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::set<RimSummaryCaseCollection*> RimAbstractCorrelationPlot::ensembles()
|
||||
std::set<RimSummaryCaseCollection*> RimAbstractCorrelationPlot::ensembles() const
|
||||
{
|
||||
RiaSummaryCurveDefinitionAnalyser* analyserOfSelectedCurveDefs = getOrCreateSelectedCurveDefAnalyser();
|
||||
return analyserOfSelectedCurveDefs->m_ensembles;
|
||||
@@ -554,6 +553,8 @@ RiuPlotWidget* RimAbstractCorrelationPlot::doCreatePlotViewWidget( QWidget* main
|
||||
{
|
||||
m_plotWidget = new RiuQwtPlotWidget( this, mainWindowParent );
|
||||
updatePlotTitle();
|
||||
|
||||
new RiuContextMenuLauncher( m_plotWidget, { "RicShowPlotDataFeature" } );
|
||||
}
|
||||
|
||||
return m_plotWidget;
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
std::vector<RiaSummaryCurveDefinition> curveDefinitions() const;
|
||||
void setCurveDefinitions( const std::vector<RiaSummaryCurveDefinition>& curveDefinitions );
|
||||
void setTimeStep( std::time_t timeStep );
|
||||
std::set<RimSummaryCaseCollection*> ensembles();
|
||||
std::set<RimSummaryCaseCollection*> ensembles() const;
|
||||
|
||||
// Get summary cases filtered by attached ensemble parameter filter
|
||||
std::set<RimSummaryCase*> filterEnsembleCases( RimSummaryCaseCollection* ensemble ) const;
|
||||
@@ -85,7 +85,7 @@ protected:
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
|
||||
|
||||
std::set<RifEclipseSummaryAddress> addresses();
|
||||
std::set<RifEclipseSummaryAddress> addresses() const;
|
||||
std::set<RigEnsembleParameter> ensembleParameters();
|
||||
std::set<RigEnsembleParameter> variationSortedEnsembleParameters();
|
||||
RigEnsembleParameter ensembleParameter( const QString& ensembleParameterName );
|
||||
@@ -128,7 +128,7 @@ private:
|
||||
void connectCurveFilterSignals();
|
||||
void onFilterSourceChanged( const caf::SignalEmitter* emitter );
|
||||
|
||||
RiaSummaryCurveDefinitionAnalyser* getOrCreateSelectedCurveDefAnalyser();
|
||||
RiaSummaryCurveDefinitionAnalyser* getOrCreateSelectedCurveDefAnalyser() const;
|
||||
|
||||
protected:
|
||||
std::unique_ptr<RiaSummaryCurveDefinitionAnalyser> m_analyserOfSelectedCurveDefs;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "RiaStatisticsTools.h"
|
||||
#include "RiaSummaryCurveDefinition.h"
|
||||
|
||||
#include "RifCsvDataTableFormatter.h"
|
||||
#include "RifSummaryReaderInterface.h"
|
||||
|
||||
#include "RigEnsembleParameter.h"
|
||||
@@ -108,44 +109,6 @@ private:
|
||||
std::map<size_t, QString> m_tickLabels;
|
||||
};
|
||||
|
||||
template <typename KeyType, typename ValueType>
|
||||
class CorrelationMatrixRowOrColumn
|
||||
{
|
||||
public:
|
||||
CorrelationMatrixRowOrColumn( const KeyType& key, const std::vector<double>& correlations, const std::vector<ValueType>& values )
|
||||
: m_key( key )
|
||||
, m_correlations( correlations )
|
||||
, m_values( values )
|
||||
, m_correlationSum( 0.0 )
|
||||
, m_correlationAbsSum( 0.0 )
|
||||
{
|
||||
bool anyValid = false;
|
||||
for ( auto value : correlations )
|
||||
{
|
||||
if ( RiaCurveDataTools::isValidValue( value, false ) )
|
||||
{
|
||||
m_correlationSum += value;
|
||||
m_correlationAbsSum += std::abs( value );
|
||||
anyValid = true;
|
||||
}
|
||||
}
|
||||
if ( !anyValid )
|
||||
{
|
||||
m_correlationSum = std::numeric_limits<double>::infinity();
|
||||
m_correlationAbsSum = std::numeric_limits<double>::infinity();
|
||||
}
|
||||
}
|
||||
|
||||
KeyType m_key;
|
||||
std::vector<double> m_correlations;
|
||||
std::vector<ValueType> m_values;
|
||||
double m_correlationSum;
|
||||
double m_correlationAbsSum;
|
||||
};
|
||||
|
||||
using CorrelationMatrixColumn = CorrelationMatrixRowOrColumn<QString, RiaSummaryCurveDefinition>;
|
||||
using CorrelationMatrixRow = CorrelationMatrixRowOrColumn<RiaSummaryCurveDefinition, QString>;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -249,6 +212,45 @@ bool RimCorrelationMatrixPlot::isCurveHighlightSupported() const
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimCorrelationMatrixPlot::asciiDataForPlotExport() const
|
||||
{
|
||||
QString text;
|
||||
|
||||
QTextStream stream( &text );
|
||||
QString fieldSeparator = "\t";
|
||||
RifCsvDataTableFormatter formatter( stream, fieldSeparator );
|
||||
formatter.setUseQuotes( false );
|
||||
|
||||
std::vector<RifTextDataTableColumn> header;
|
||||
header.emplace_back( RifTextDataTableColumn( "Vector" ) );
|
||||
|
||||
for ( const auto& param : m_paramLabels )
|
||||
{
|
||||
header.emplace_back( RifTextDataTableColumn( param.second ) );
|
||||
}
|
||||
|
||||
formatter.header( header );
|
||||
|
||||
for ( const auto& row : m_valuesForTextReport )
|
||||
{
|
||||
formatter.add( QString::fromStdString( row.m_key.summaryAddressY().uiText() ) );
|
||||
|
||||
for ( const auto& corr : row.m_correlations )
|
||||
{
|
||||
formatter.add( corr );
|
||||
}
|
||||
|
||||
formatter.rowCompleted();
|
||||
}
|
||||
|
||||
formatter.tableCompleted();
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -645,6 +647,8 @@ void RimCorrelationMatrixPlot::createMatrix()
|
||||
|
||||
m_resultLabels[rowIdx] = resultLabel;
|
||||
}
|
||||
|
||||
m_valuesForTextReport = correlationMatrixRows;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
|
||||
#include "RimAbstractCorrelationPlot.h"
|
||||
|
||||
#include "RiaCurveDataTools.h"
|
||||
#include "RiaSummaryCurveDefinition.h"
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
|
||||
class RimRegularLegendConfig;
|
||||
@@ -28,6 +31,48 @@ class RimSummaryAddress;
|
||||
class RiuGroupedBarChartBuilder;
|
||||
class RiuPlotItem;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
template <typename KeyType, typename ValueType>
|
||||
class CorrelationMatrixRowOrColumn
|
||||
{
|
||||
public:
|
||||
CorrelationMatrixRowOrColumn( const KeyType& key, const std::vector<double>& correlations, const std::vector<ValueType>& values )
|
||||
: m_key( key )
|
||||
, m_correlations( correlations )
|
||||
, m_values( values )
|
||||
, m_correlationSum( 0.0 )
|
||||
, m_correlationAbsSum( 0.0 )
|
||||
{
|
||||
bool anyValid = false;
|
||||
for ( auto value : correlations )
|
||||
{
|
||||
if ( RiaCurveDataTools::isValidValue( value, false ) )
|
||||
{
|
||||
m_correlationSum += value;
|
||||
m_correlationAbsSum += std::abs( value );
|
||||
anyValid = true;
|
||||
}
|
||||
}
|
||||
if ( !anyValid )
|
||||
{
|
||||
m_correlationSum = std::numeric_limits<double>::infinity();
|
||||
m_correlationAbsSum = std::numeric_limits<double>::infinity();
|
||||
}
|
||||
}
|
||||
|
||||
KeyType m_key;
|
||||
std::vector<double> m_correlations;
|
||||
std::vector<ValueType> m_values;
|
||||
double m_correlationSum;
|
||||
double m_correlationAbsSum;
|
||||
};
|
||||
|
||||
using CorrelationMatrixColumn = CorrelationMatrixRowOrColumn<QString, RiaSummaryCurveDefinition>;
|
||||
using CorrelationMatrixRow = CorrelationMatrixRowOrColumn<RiaSummaryCurveDefinition, QString>;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
@@ -60,6 +105,7 @@ public:
|
||||
bool showTopNCorrelations() const;
|
||||
int topNFilterCount() const;
|
||||
bool isCurveHighlightSupported() const override;
|
||||
QString asciiDataForPlotExport() const override;
|
||||
|
||||
private:
|
||||
// Overridden PDM methods
|
||||
@@ -94,4 +140,6 @@ private:
|
||||
|
||||
std::map<size_t, QString> m_paramLabels;
|
||||
std::map<size_t, QString> m_resultLabels;
|
||||
|
||||
std::vector<CorrelationMatrixRow> m_valuesForTextReport;
|
||||
};
|
||||
|
||||
@@ -230,7 +230,7 @@ void RimCorrelationPlot::updateAxes()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCorrelationPlot::addDataToChartBuilder( RiuGroupedBarChartBuilder& chartBuilder )
|
||||
void RimCorrelationPlot::addDataToChartBuilder( RiuGroupedBarChartBuilder& chartBuilder ) const
|
||||
{
|
||||
time_t selectedTimestep = m_timeStep().toSecsSinceEpoch();
|
||||
|
||||
@@ -295,6 +295,17 @@ void RimCorrelationPlot::onPlotItemSelected( std::shared_ptr<RiuPlotItem> plotIt
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimCorrelationPlot::asciiDataForPlotExport() const
|
||||
{
|
||||
RiuGroupedBarChartBuilder chartBuilder;
|
||||
addDataToChartBuilder( chartBuilder );
|
||||
|
||||
return chartBuilder.plotContentAsText();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -61,15 +61,14 @@ private:
|
||||
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
|
||||
|
||||
void onLoadDataAndUpdate() override;
|
||||
|
||||
void updateAxes() override;
|
||||
void onLoadDataAndUpdate() override;
|
||||
void updateAxes() override;
|
||||
QString asciiDataForPlotExport() const override;
|
||||
|
||||
// Private methods
|
||||
void addDataToChartBuilder( RiuGroupedBarChartBuilder& chartBuilder );
|
||||
void addDataToChartBuilder( RiuGroupedBarChartBuilder& chartBuilder ) const;
|
||||
void updatePlotTitle() override;
|
||||
void onPlotItemSelected( std::shared_ptr<RiuPlotItem> plotItem, bool toggle, int sampleIndex ) override;
|
||||
|
||||
|
||||
@@ -223,6 +223,7 @@ QStringList caseNamesOfValidEnsembleCases( const RimSummaryCaseCollection* ensem
|
||||
void RimParameterResultCrossPlot::createPoints()
|
||||
{
|
||||
detachAllCurves();
|
||||
m_valuesForTextReport.clear();
|
||||
|
||||
time_t selectedTimestep = m_timeStep().toSecsSinceEpoch();
|
||||
|
||||
@@ -285,6 +286,8 @@ void RimParameterResultCrossPlot::createPoints()
|
||||
double paramValue = parameter.values[caseIdx].toDouble();
|
||||
parameterValues.push_back( paramValue );
|
||||
|
||||
m_valuesForTextReport.push_back( { paramValue, closestValue } );
|
||||
|
||||
m_xRange.first = std::min( m_xRange.first, paramValue );
|
||||
m_xRange.second = std::max( m_xRange.second, paramValue );
|
||||
|
||||
@@ -314,6 +317,22 @@ void RimParameterResultCrossPlot::createPoints()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimParameterResultCrossPlot::asciiDataForPlotExport() const
|
||||
{
|
||||
QString asciiData;
|
||||
|
||||
asciiData += "Parameter\tResult\n";
|
||||
for ( const auto& valuePair : m_valuesForTextReport )
|
||||
{
|
||||
asciiData += QString( "%1\t%2\n" ).arg( valuePair.first ).arg( valuePair.second );
|
||||
}
|
||||
|
||||
return asciiData;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -41,9 +41,9 @@ private:
|
||||
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
|
||||
|
||||
void onLoadDataAndUpdate() override;
|
||||
|
||||
void updateAxes() override;
|
||||
void onLoadDataAndUpdate() override;
|
||||
void updateAxes() override;
|
||||
QString asciiDataForPlotExport() const override;
|
||||
|
||||
// Private methods
|
||||
void updatePlotTitle() override;
|
||||
@@ -54,4 +54,6 @@ private:
|
||||
|
||||
std::pair<double, double> m_xRange;
|
||||
std::pair<double, double> m_yRange;
|
||||
|
||||
std::vector<std::pair<double, double>> m_valuesForTextReport;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user