mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-20 11:48:35 -06:00
#6253 Support creating analysis plots directly from an ensemble plot
This commit is contained in:
parent
b7e1d6e377
commit
698677f3ac
@ -18,8 +18,12 @@
|
||||
|
||||
#include "RicNewAnalysisPlotFeature.h"
|
||||
|
||||
#include "CorrelationPlotCommands/RicNewCorrelationPlotFeature.h"
|
||||
|
||||
#include "RimAnalysisPlot.h"
|
||||
#include "RimAnalysisPlotCollection.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
|
||||
#include "RiuPlotMainWindowTools.h"
|
||||
|
||||
@ -44,6 +48,10 @@ bool RicNewAnalysisPlotFeature::isCommandEnabled()
|
||||
|
||||
if ( analysisPlotColl ) return true;
|
||||
|
||||
RimSummaryPlot* summaryPlot = nullptr;
|
||||
selObj->firstAncestorOrThisOfType( summaryPlot );
|
||||
if ( summaryPlot ) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -60,9 +68,33 @@ void RicNewAnalysisPlotFeature::onActionTriggered( bool isChecked )
|
||||
selObj->firstAncestorOrThisOfType( analysisPlotColl );
|
||||
}
|
||||
|
||||
if ( !analysisPlotColl ) return;
|
||||
RimSummaryCaseCollection* ensemble = nullptr;
|
||||
QString quantityName;
|
||||
std::time_t timeStep = 0;
|
||||
|
||||
auto newPlot = analysisPlotColl->createAnalysisPlot();
|
||||
RimAnalysisPlot* newPlot = nullptr;
|
||||
if ( !analysisPlotColl )
|
||||
{
|
||||
QVariant userData = this->userData();
|
||||
if ( !userData.isNull() && userData.canConvert<EnsemblePlotParams>() )
|
||||
{
|
||||
std::vector<RimAnalysisPlotCollection*> correlationPlotCollections;
|
||||
RimProject::current()->descendantsOfType( correlationPlotCollections );
|
||||
CAF_ASSERT( !correlationPlotCollections.empty() );
|
||||
analysisPlotColl = correlationPlotCollections.front();
|
||||
|
||||
EnsemblePlotParams params = userData.value<EnsemblePlotParams>();
|
||||
ensemble = params.ensemble;
|
||||
quantityName = params.quantityName;
|
||||
timeStep = params.timeStep;
|
||||
|
||||
newPlot = analysisPlotColl->createAnalysisPlot( ensemble, quantityName, timeStep );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newPlot = analysisPlotColl->createAnalysisPlot();
|
||||
}
|
||||
newPlot->loadDataAndUpdate();
|
||||
|
||||
analysisPlotColl->updateConnectedEditors();
|
||||
|
@ -76,16 +76,16 @@ void RicNewCorrelationMatrixPlotFeature::onActionTriggered( bool isChecked )
|
||||
if ( !correlationPlotColl )
|
||||
{
|
||||
QVariant userData = this->userData();
|
||||
if ( !userData.isNull() && userData.canConvert<CorrelationPlotParams>() )
|
||||
if ( !userData.isNull() && userData.canConvert<EnsemblePlotParams>() )
|
||||
{
|
||||
std::vector<RimCorrelationPlotCollection*> correlationPlotCollections;
|
||||
RimProject::current()->descendantsOfType( correlationPlotCollections );
|
||||
CAF_ASSERT( !correlationPlotCollections.empty() );
|
||||
correlationPlotColl = correlationPlotCollections.front();
|
||||
|
||||
CorrelationPlotParams params = userData.value<CorrelationPlotParams>();
|
||||
ensemble = params.ensemble;
|
||||
timeStep = params.timeStep;
|
||||
EnsemblePlotParams params = userData.value<EnsemblePlotParams>();
|
||||
ensemble = params.ensemble;
|
||||
timeStep = params.timeStep;
|
||||
|
||||
newPlot = correlationPlotColl->createCorrelationMatrixPlot( ensemble, timeStep );
|
||||
}
|
||||
|
@ -74,17 +74,17 @@ void RicNewCorrelationPlotFeature::onActionTriggered( bool isChecked )
|
||||
if ( !correlationPlotColl )
|
||||
{
|
||||
QVariant userData = this->userData();
|
||||
if ( !userData.isNull() && userData.canConvert<CorrelationPlotParams>() )
|
||||
if ( !userData.isNull() && userData.canConvert<EnsemblePlotParams>() )
|
||||
{
|
||||
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;
|
||||
EnsemblePlotParams params = userData.value<EnsemblePlotParams>();
|
||||
ensemble = params.ensemble;
|
||||
quantityName = params.quantityName;
|
||||
timeStep = params.timeStep;
|
||||
|
||||
newPlot = correlationPlotColl->createCorrelationPlot( ensemble, quantityName, timeStep );
|
||||
}
|
||||
@ -114,7 +114,7 @@ void RicNewCorrelationPlotFeature::setupActionLook( QAction* actionToSetup )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
CorrelationPlotParams::CorrelationPlotParams()
|
||||
EnsemblePlotParams::EnsemblePlotParams()
|
||||
: ensemble( nullptr )
|
||||
, quantityName( "" )
|
||||
, ensembleParameter( "" )
|
||||
@ -125,9 +125,9 @@ CorrelationPlotParams::CorrelationPlotParams()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
CorrelationPlotParams::CorrelationPlotParams( RimSummaryCaseCollection* ensemble,
|
||||
const QString& quantityName,
|
||||
const std::time_t& timeStep )
|
||||
EnsemblePlotParams::EnsemblePlotParams( RimSummaryCaseCollection* ensemble,
|
||||
const QString& quantityName,
|
||||
const std::time_t& timeStep )
|
||||
: ensemble( ensemble )
|
||||
, quantityName( quantityName )
|
||||
, ensembleParameter( "" )
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
class RimSummaryCaseCollection;
|
||||
|
||||
class CorrelationPlotParams
|
||||
class EnsemblePlotParams
|
||||
{
|
||||
public:
|
||||
RimSummaryCaseCollection* ensemble;
|
||||
@ -32,14 +32,14 @@ public:
|
||||
QString ensembleParameter;
|
||||
std::time_t timeStep;
|
||||
|
||||
CorrelationPlotParams();
|
||||
CorrelationPlotParams( const CorrelationPlotParams& rhs ) = default;
|
||||
EnsemblePlotParams();
|
||||
EnsemblePlotParams( const EnsemblePlotParams& rhs ) = default;
|
||||
|
||||
CorrelationPlotParams( RimSummaryCaseCollection* ensemble, const QString& quantityName, const std::time_t& timeStep );
|
||||
~CorrelationPlotParams() = default;
|
||||
EnsemblePlotParams( RimSummaryCaseCollection* ensemble, const QString& quantityName, const std::time_t& timeStep );
|
||||
~EnsemblePlotParams() = default;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE( CorrelationPlotParams );
|
||||
Q_DECLARE_METATYPE( EnsemblePlotParams );
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
|
@ -75,17 +75,17 @@ void RicNewCorrelationReportPlotFeature::onActionTriggered( bool isChecked )
|
||||
if ( !correlationPlotColl )
|
||||
{
|
||||
QVariant userData = this->userData();
|
||||
if ( !userData.isNull() && userData.canConvert<CorrelationPlotParams>() )
|
||||
if ( !userData.isNull() && userData.canConvert<EnsemblePlotParams>() )
|
||||
{
|
||||
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;
|
||||
EnsemblePlotParams params = userData.value<EnsemblePlotParams>();
|
||||
ensemble = params.ensemble;
|
||||
quantityName = params.quantityName;
|
||||
timeStep = params.timeStep;
|
||||
|
||||
newPlot = correlationPlotColl->createCorrelationReportPlot( ensemble, quantityName, timeStep );
|
||||
}
|
||||
|
@ -77,17 +77,17 @@ void RicNewParameterResultCrossPlotFeature::onActionTriggered( bool isChecked )
|
||||
if ( !correlationPlotColl )
|
||||
{
|
||||
QVariant userData = this->userData();
|
||||
if ( !userData.isNull() && userData.canConvert<CorrelationPlotParams>() )
|
||||
if ( !userData.isNull() && userData.canConvert<EnsemblePlotParams>() )
|
||||
{
|
||||
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;
|
||||
ensembleParameter = params.ensembleParameter;
|
||||
EnsemblePlotParams params = userData.value<EnsemblePlotParams>();
|
||||
ensemble = params.ensemble;
|
||||
quantityName = params.quantityName;
|
||||
ensembleParameter = params.ensembleParameter;
|
||||
|
||||
timeStep = params.timeStep;
|
||||
|
||||
|
@ -214,6 +214,18 @@ void RimAnalysisPlot::setCurveDefinitions( const std::vector<RiaSummaryCurveDefi
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimAnalysisPlot::setTimeSteps( const std::vector<time_t>& timeSteps )
|
||||
{
|
||||
m_selectedTimeSteps.v().clear();
|
||||
for ( auto time : timeSteps )
|
||||
{
|
||||
m_selectedTimeSteps.v().push_back( RiaQDateTimeTools::fromTime_t( time ) );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -79,6 +79,7 @@ public:
|
||||
RimPlotDataFilterCollection* plotDataFilterCollection() const;
|
||||
|
||||
void setCurveDefinitions( const std::vector<RiaSummaryCurveDefinition>& curveDefinitions );
|
||||
void setTimeSteps( const std::vector<time_t>& timeSteps );
|
||||
|
||||
std::set<RifEclipseSummaryAddress> unfilteredAddresses();
|
||||
std::set<EnsembleParameter> ensembleParameters();
|
||||
|
@ -60,6 +60,27 @@ RimAnalysisPlot* RimAnalysisPlotCollection::createAnalysisPlot()
|
||||
return plot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimAnalysisPlot* RimAnalysisPlotCollection::createAnalysisPlot( RimSummaryCaseCollection* ensemble,
|
||||
const QString& quantityName,
|
||||
std::time_t timeStep )
|
||||
{
|
||||
RimAnalysisPlot* plot = new RimAnalysisPlot();
|
||||
plot->setAsPlotMdiWindow();
|
||||
|
||||
applyEnsembleFieldAndTimeStepToPlot( plot, ensemble, quantityName.toStdString(), timeStep );
|
||||
|
||||
// plot->enableAutoPlotTitle( true );
|
||||
m_analysisPlots.push_back( plot );
|
||||
|
||||
plot->loadDataAndUpdate();
|
||||
plot->updateConnectedEditors();
|
||||
|
||||
return plot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -123,3 +144,30 @@ void RimAnalysisPlotCollection::applyFirstEnsembleFieldAddressesToPlot( RimAnaly
|
||||
plot->setCurveDefinitions( curveDefs );
|
||||
}
|
||||
}
|
||||
|
||||
void RimAnalysisPlotCollection::applyEnsembleFieldAndTimeStepToPlot( RimAnalysisPlot* plot,
|
||||
RimSummaryCaseCollection* ensemble,
|
||||
const std::string& quantityName,
|
||||
std::time_t timeStep )
|
||||
{
|
||||
if ( ensemble )
|
||||
{
|
||||
std::set<RifEclipseSummaryAddress> allAddresses = ensemble->ensembleSummaryAddresses();
|
||||
std::vector<RiaSummaryCurveDefinition> curveDefs;
|
||||
for ( auto address : allAddresses )
|
||||
{
|
||||
if ( address.category() == RifEclipseSummaryAddress::SUMMARY_FIELD )
|
||||
{
|
||||
if ( quantityName.empty() || quantityName == address.quantityName() )
|
||||
{
|
||||
for ( auto summaryCase : ensemble->allSummaryCases() )
|
||||
{
|
||||
curveDefs.push_back( RiaSummaryCurveDefinition( summaryCase, address, nullptr ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
plot->setCurveDefinitions( curveDefs );
|
||||
plot->setTimeSteps( {timeStep} );
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,10 @@
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
#include <ctime>
|
||||
|
||||
class RimAnalysisPlot;
|
||||
class RimSummaryCaseCollection;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -36,8 +39,11 @@ public:
|
||||
~RimAnalysisPlotCollection() override;
|
||||
|
||||
RimAnalysisPlot* createAnalysisPlot();
|
||||
void updateSummaryNameHasChanged();
|
||||
void removeSummaryPlot( RimAnalysisPlot* analysisPlot );
|
||||
RimAnalysisPlot*
|
||||
createAnalysisPlot( RimSummaryCaseCollection* ensemble, const QString& quantityName, std::time_t timeStep );
|
||||
|
||||
void updateSummaryNameHasChanged();
|
||||
void removeSummaryPlot( RimAnalysisPlot* analysisPlot );
|
||||
|
||||
std::vector<RimAnalysisPlot*> plots();
|
||||
|
||||
@ -45,6 +51,10 @@ public:
|
||||
|
||||
private:
|
||||
void applyFirstEnsembleFieldAddressesToPlot( RimAnalysisPlot* plot, const std::string& quantityName = "" );
|
||||
void applyEnsembleFieldAndTimeStepToPlot( RimAnalysisPlot* plot,
|
||||
RimSummaryCaseCollection* ensemble,
|
||||
const std::string& quantityName,
|
||||
std::time_t timeStep );
|
||||
|
||||
private:
|
||||
caf::PdmChildArrayField<RimAnalysisPlot*> m_analysisPlots;
|
||||
|
@ -207,11 +207,14 @@ void RiuSummaryQwtPlot::contextMenuEvent( QContextMenuEvent* event )
|
||||
RimSummaryCaseCollection* ensemble = ensembleCurveSet->summaryCaseCollection();
|
||||
if ( ensemble && ensemble->isEnsemble() )
|
||||
{
|
||||
CorrelationPlotParams params( ensemble,
|
||||
QString::fromStdString(
|
||||
ensembleCurveSet->summaryAddress().quantityName() ),
|
||||
timeStep );
|
||||
QVariant variant = QVariant::fromValue( params );
|
||||
EnsemblePlotParams params( ensemble,
|
||||
QString::fromStdString(
|
||||
ensembleCurveSet->summaryAddress().quantityName() ),
|
||||
timeStep );
|
||||
QVariant variant = QVariant::fromValue( params );
|
||||
|
||||
menuBuilder.addCmdFeatureWithUserData( "RicNewAnalysisPlotFeature", "New Analysis Plot", variant );
|
||||
|
||||
menuBuilder.subMenuStart( "Create Correlation Plot From Curve Point",
|
||||
*caf::IconProvider( ":/CorrelationPlots16x16.png" ).icon() );
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user