#6237 Implement creation of correlation plot from ensemble plots

This commit is contained in:
Gaute Lindkvist
2020-07-28 15:13:39 +02:00
parent 447d335fc8
commit aeecaa3ff1
12 changed files with 434 additions and 20 deletions

View File

@@ -20,6 +20,8 @@
#include "RimCorrelationPlot.h"
#include "RimCorrelationPlotCollection.h"
#include "RimProject.h"
#include "RimSummaryPlot.h"
#include "RiuPlotMainWindowTools.h"
@@ -44,6 +46,10 @@ bool RicNewCorrelationPlotFeature::isCommandEnabled()
if ( correlationPlotColl ) return true;
RimSummaryPlot* summaryPlot = nullptr;
selObj->firstAncestorOrThisOfType( summaryPlot );
if ( summaryPlot ) return true;
return false;
}
@@ -60,9 +66,34 @@ void RicNewCorrelationPlotFeature::onActionTriggered( bool isChecked )
selObj->firstAncestorOrThisOfType( correlationPlotColl );
}
if ( !correlationPlotColl ) return;
RimSummaryCaseCollection* ensemble = nullptr;
QString quantityName;
std::time_t timeStep = 0;
RimCorrelationPlot* newPlot = nullptr;
if ( !correlationPlotColl )
{
QVariant userData = this->userData();
if ( !userData.isNull() && userData.canConvert<CorrelationPlotParams>() )
{
std::vector<RimCorrelationPlotCollection*> correlationPlotCollections;
RimProject::current()->descendantsOfType( correlationPlotCollections );
CAF_ASSERT( !correlationPlotCollections.empty() );
correlationPlotColl = correlationPlotCollections.front();
CorrelationPlotParams params = userData.value<CorrelationPlotParams>();
ensemble = params.ensemble;
quantityName = params.quantityName;
timeStep = params.timeStep;
newPlot = correlationPlotColl->createCorrelationPlot( ensemble, quantityName, timeStep );
}
}
else
{
newPlot = correlationPlotColl->createCorrelationPlot();
}
auto newPlot = correlationPlotColl->createCorrelationPlot();
newPlot->loadDataAndUpdate();
correlationPlotColl->updateConnectedEditors();
@@ -79,3 +110,27 @@ void RicNewCorrelationPlotFeature::setupActionLook( QAction* actionToSetup )
actionToSetup->setText( "New Correlation Tornado Plot" );
actionToSetup->setIcon( QIcon( ":/CorrelationTornadoPlot16x16.png" ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
CorrelationPlotParams::CorrelationPlotParams()
: ensemble( nullptr )
, quantityName( "" )
, ensembleParameter( "" )
, timeStep( 0 )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
CorrelationPlotParams::CorrelationPlotParams( RimSummaryCaseCollection* ensemble,
const QString& quantityName,
const std::time_t& timeStep )
: ensemble( ensemble )
, quantityName( quantityName )
, ensembleParameter( "" )
, timeStep( timeStep )
{
}