mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 23:20:29 -05:00
#14360 Histogram Plots: Implement Show Plot Data
This commit is contained in:
1 parent
79442c0524
commit
2ebefe73b6
2 files changed
+43
-11
No files matched your search
@@ -24,10 +24,13 @@
|
||||
|
||||
#include "RicHistogramPlotTools.h"
|
||||
|
||||
#include "RifCsvDataTableFormatter.h"
|
||||
|
||||
#include "Histogram/RimEnsembleParameterHistogramDataSource.h"
|
||||
#include "Histogram/RimEnsembleSummaryVectorHistogramDataSource.h"
|
||||
#include "RimHistogramCurve.h"
|
||||
#include "RimHistogramCurveCollection.h"
|
||||
#include "RimHistogramDataSource.h"
|
||||
#include "RimMultiPlot.h"
|
||||
#include "RimPlotAxisLogRangeCalculator.h"
|
||||
#include "Summary/Ensemble/RimSummaryEnsembleParameter.h"
|
||||
@@ -35,6 +38,7 @@
|
||||
#include "Summary/RimSummaryAddress.h"
|
||||
#include "Tools/RimPlotAxisTools.h"
|
||||
|
||||
#include "RiuContextMenuLauncher.h"
|
||||
#include "RiuPlotAxis.h"
|
||||
#include "RiuPlotMainWindow.h"
|
||||
#include "RiuPlotMainWindowTools.h"
|
||||
@@ -211,16 +215,44 @@ RiuPlotWidget* RimHistogramPlot::plotWidget()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimHistogramPlot::asciiDataForPlotExport() const
|
||||
{
|
||||
return asciiDataForHistogramPlotExport( RiaDefines::DateTimePeriod::YEAR, false );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimHistogramPlot::asciiDataForHistogramPlotExport( RiaDefines::DateTimePeriod resamplingPeriod, bool showTimeAsLongString ) const
|
||||
{
|
||||
// TODO: add implementation
|
||||
QString text;
|
||||
|
||||
for ( RimHistogramCurve* curve : histogramCurves() )
|
||||
{
|
||||
if ( !curve->isChecked() || !curve->dataSource() ) continue;
|
||||
|
||||
// Compute as line graph to get one value per bin, independent of how the curve is rendered
|
||||
auto result = curve->dataSource()->compute( GraphType::LINE_GRAPH, frequencyType() );
|
||||
if ( result.valuesX.empty() || result.valuesX.size() != result.valuesY.size() ) continue;
|
||||
|
||||
QString headerX = "Bin Center";
|
||||
if ( !curve->unitNameX().empty() ) headerX += QString( " [%1]" ).arg( QString::fromStdString( curve->unitNameX() ) );
|
||||
|
||||
QString headerY = caf::AppEnum<FrequencyType>::uiText( frequencyType() );
|
||||
if ( !curve->unitNameY().empty() ) headerY += QString( " [%1]" ).arg( QString::fromStdString( curve->unitNameY() ) );
|
||||
|
||||
QString tableText;
|
||||
QTextStream stringStream( &tableText );
|
||||
|
||||
// Use tab as field separator to make the text paste into separate columns in Excel
|
||||
RifCsvDataTableFormatter formatter( stringStream, "\t" );
|
||||
formatter.setUseQuotes( false );
|
||||
|
||||
formatter.header( { RifTextDataTableColumn( headerX ), RifTextDataTableColumn( headerY ) } );
|
||||
|
||||
for ( size_t i = 0; i < result.valuesX.size(); i++ )
|
||||
{
|
||||
formatter.add( result.valuesX[i] );
|
||||
formatter.add( result.valuesY[i] );
|
||||
formatter.rowCompleted();
|
||||
}
|
||||
formatter.tableCompleted();
|
||||
|
||||
if ( !text.isEmpty() ) text += "\n";
|
||||
text += curve->curveName() + "\n";
|
||||
text += tableText;
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -1026,6 +1058,8 @@ RiuPlotWidget* RimHistogramPlot::doCreatePlotViewWidget( QWidget* mainWindowPare
|
||||
{
|
||||
m_histogramPlot = new RiuQwtPlotWidget( this, mainWindowParent );
|
||||
|
||||
new RiuContextMenuLauncher( m_histogramPlot, { "RicShowPlotDataFeature" } );
|
||||
|
||||
QObject::connect( plotWidget(), SIGNAL( curveOrderNeedsUpdate() ), this, SLOT( onUpdateCurveOrder() ) );
|
||||
|
||||
for ( const auto& axisProperties : m_axisPropertiesArray )
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RiaDateTimeDefines.h"
|
||||
#include "RiaPlotDefines.h"
|
||||
|
||||
#include "RimPlot.h"
|
||||
@@ -104,7 +103,6 @@ public:
|
||||
QWidget* viewWidget() override;
|
||||
|
||||
QString asciiDataForPlotExport() const override;
|
||||
QString asciiDataForHistogramPlotExport( RiaDefines::DateTimePeriod resamplingPeriod, bool showTimeAsLongString ) const;
|
||||
|
||||
FrequencyType frequencyType() const;
|
||||
GraphType graphType() const;
|
||||
|
||||
Reference in new issue
Block a user