Skip to content

Commit

Permalink
Show plot data for correlation report in three separate text dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Oct 10, 2023
1 parent d63f648 commit 689d026
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@

#include "RimAnalysisPlot.h"
#include "RimCorrelationMatrixPlot.h"
#include "RimCorrelationPlot.h"
#include "RimCorrelationReportPlot.h"
#include "RimGridCrossPlot.h"
#include "RimGridCrossPlotCurve.h"
#include "RimParameterResultCrossPlot.h"
#include "RimPlotWindow.h"
#include "RimProject.h"
#include "RimSummaryPlot.h"
Expand Down Expand Up @@ -191,7 +194,8 @@ bool RicShowPlotDataFeature::isCommandEnabled() const
if ( dynamic_cast<RimSummaryPlot*>( plot ) || dynamic_cast<RimWellLogPlot*>( plot ) || dynamic_cast<RimWellLogTrack*>( plot ) ||
dynamic_cast<RimGridCrossPlot*>( plot ) || dynamic_cast<RimVfpPlot*>( plot ) ||
dynamic_cast<RimWellAllocationOverTimePlot*>( plot ) || dynamic_cast<RimAnalysisPlot*>( plot ) ||
dynamic_cast<RimCorrelationMatrixPlot*>( plot ) || dynamic_cast<RimAbstractCorrelationPlot*>( plot ) )
dynamic_cast<RimCorrelationMatrixPlot*>( plot ) || dynamic_cast<RimAbstractCorrelationPlot*>( plot ) ||
dynamic_cast<RimCorrelationReportPlot*>( plot ) )
{
validPlots++;
}
Expand Down Expand Up @@ -246,6 +250,17 @@ void RicShowPlotDataFeature::onActionTriggered( bool isChecked )
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 rimPlot = dynamic_cast<RimPlot*>( plot ) )
{
rimPlots.push_back( rimPlot );
Expand All @@ -266,7 +281,11 @@ void RicShowPlotDataFeature::onActionTriggered( bool isChecked )
for ( auto rimPlot : rimPlots )
{
QString title = rimPlot->description();
QString text = rimPlot->asciiDataForPlotExport();
QString text = title;
text += "\n";
text += "\n";
text += rimPlot->asciiDataForPlotExport();

RicShowPlotDataFeature::showTextWindow( title, text );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -935,10 +935,7 @@ QString RimAnalysisPlot::asciiDataForPlotExport() const
RiuGroupedBarChartBuilder chartBuilder;
addDataToChartBuilder( chartBuilder );

QString text = description() + "\n\n";
text += chartBuilder.plotContentAsText();

return text;
return chartBuilder.plotContentAsText();
}

//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ QStringList caseNamesOfValidEnsembleCases( const RimSummaryCaseCollection* ensem
void RimParameterResultCrossPlot::createPoints()
{
detachAllCurves();
m_valuesForTextReport.clear();

time_t selectedTimestep = m_timeStep().toSecsSinceEpoch();

Expand Down Expand Up @@ -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 );

Expand Down Expand Up @@ -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;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ class RimParameterResultCrossPlot : public RimAbstractCorrelationPlot

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;
Expand All @@ -54,4 +54,6 @@ class RimParameterResultCrossPlot : public RimAbstractCorrelationPlot

std::pair<double, double> m_xRange;
std::pair<double, double> m_yRange;

std::vector<std::pair<double, double>> m_valuesForTextReport;
};

0 comments on commit 689d026

Please sign in to comment.