mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#6237 Implement creation of correlation plot from ensemble plots
This commit is contained in:
parent
447d335fc8
commit
aeecaa3ff1
@ -18,9 +18,13 @@
|
||||
|
||||
#include "RicNewCorrelationMatrixPlotFeature.h"
|
||||
|
||||
#include "RicNewCorrelationPlotFeature.h"
|
||||
|
||||
#include "RimCorrelationMatrixPlot.h"
|
||||
#include "RimCorrelationPlot.h"
|
||||
#include "RimCorrelationPlotCollection.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
|
||||
#include "RiuPlotMainWindowTools.h"
|
||||
|
||||
@ -45,6 +49,10 @@ bool RicNewCorrelationMatrixPlotFeature::isCommandEnabled()
|
||||
|
||||
if ( correlationPlotColl ) return true;
|
||||
|
||||
RimSummaryPlot* summaryPlot = nullptr;
|
||||
selObj->firstAncestorOrThisOfType( summaryPlot );
|
||||
if ( summaryPlot ) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -61,9 +69,32 @@ void RicNewCorrelationMatrixPlotFeature::onActionTriggered( bool isChecked )
|
||||
selObj->firstAncestorOrThisOfType( correlationPlotColl );
|
||||
}
|
||||
|
||||
if ( !correlationPlotColl ) return;
|
||||
RimSummaryCaseCollection* ensemble = nullptr;
|
||||
std::time_t timeStep = 0;
|
||||
|
||||
RimCorrelationMatrixPlot* 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;
|
||||
timeStep = params.timeStep;
|
||||
|
||||
newPlot = correlationPlotColl->createCorrelationMatrixPlot( ensemble, timeStep );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newPlot = correlationPlotColl->createCorrelationMatrixPlot();
|
||||
}
|
||||
|
||||
auto newPlot = correlationPlotColl->createCorrelationMatrixPlot();
|
||||
newPlot->loadDataAndUpdate();
|
||||
|
||||
correlationPlotColl->updateConnectedEditors();
|
||||
|
@ -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 )
|
||||
{
|
||||
}
|
||||
|
@ -20,6 +20,27 @@
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
#include <ctime>
|
||||
|
||||
class RimSummaryCaseCollection;
|
||||
|
||||
class CorrelationPlotParams
|
||||
{
|
||||
public:
|
||||
RimSummaryCaseCollection* ensemble;
|
||||
QString quantityName;
|
||||
QString ensembleParameter;
|
||||
std::time_t timeStep;
|
||||
|
||||
CorrelationPlotParams();
|
||||
CorrelationPlotParams( const CorrelationPlotParams& rhs ) = default;
|
||||
|
||||
CorrelationPlotParams( RimSummaryCaseCollection* ensemble, const QString& quantityName, const std::time_t& timeStep );
|
||||
~CorrelationPlotParams() = default;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE( CorrelationPlotParams );
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
|
@ -17,9 +17,12 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicNewCorrelationReportPlotFeature.h"
|
||||
#include "RicNewCorrelationPlotFeature.h"
|
||||
|
||||
#include "RimCorrelationPlotCollection.h"
|
||||
#include "RimCorrelationReportPlot.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
|
||||
#include "RiuPlotMainWindowTools.h"
|
||||
|
||||
@ -44,6 +47,10 @@ bool RicNewCorrelationReportPlotFeature::isCommandEnabled()
|
||||
|
||||
if ( correlationPlotColl ) return true;
|
||||
|
||||
RimSummaryPlot* summaryPlot = nullptr;
|
||||
selObj->firstAncestorOrThisOfType( summaryPlot );
|
||||
if ( summaryPlot ) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -60,9 +67,33 @@ void RicNewCorrelationReportPlotFeature::onActionTriggered( bool isChecked )
|
||||
selObj->firstAncestorOrThisOfType( correlationPlotColl );
|
||||
}
|
||||
|
||||
if ( !correlationPlotColl ) return;
|
||||
RimSummaryCaseCollection* ensemble = nullptr;
|
||||
QString quantityName;
|
||||
std::time_t timeStep = 0;
|
||||
|
||||
auto newPlot = correlationPlotColl->createCorrelationReportPlot();
|
||||
RimCorrelationReportPlot* 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->createCorrelationReportPlot( ensemble, quantityName, timeStep );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newPlot = correlationPlotColl->createCorrelationReportPlot();
|
||||
}
|
||||
newPlot->loadDataAndUpdate();
|
||||
|
||||
correlationPlotColl->updateConnectedEditors();
|
||||
|
@ -18,8 +18,12 @@
|
||||
|
||||
#include "RicNewParameterResultCrossPlotFeature.h"
|
||||
|
||||
#include "RicNewCorrelationPlotFeature.h"
|
||||
|
||||
#include "RimCorrelationPlotCollection.h"
|
||||
#include "RimParameterResultCrossPlot.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
|
||||
#include "RiuPlotMainWindowTools.h"
|
||||
|
||||
@ -44,6 +48,10 @@ bool RicNewParameterResultCrossPlotFeature::isCommandEnabled()
|
||||
|
||||
if ( correlationPlotColl ) return true;
|
||||
|
||||
RimSummaryPlot* summaryPlot = nullptr;
|
||||
selObj->firstAncestorOrThisOfType( summaryPlot );
|
||||
if ( summaryPlot ) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -60,9 +68,38 @@ void RicNewParameterResultCrossPlotFeature::onActionTriggered( bool isChecked )
|
||||
selObj->firstAncestorOrThisOfType( correlationPlotColl );
|
||||
}
|
||||
|
||||
if ( !correlationPlotColl ) return;
|
||||
RimSummaryCaseCollection* ensemble = nullptr;
|
||||
QString quantityName;
|
||||
QString ensembleParameter;
|
||||
std::time_t timeStep = 0;
|
||||
|
||||
RimParameterResultCrossPlot* 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;
|
||||
ensembleParameter = params.ensembleParameter;
|
||||
|
||||
timeStep = params.timeStep;
|
||||
|
||||
newPlot =
|
||||
correlationPlotColl->createParameterResultCrossPlot( ensemble, ensembleParameter, quantityName, timeStep );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newPlot = correlationPlotColl->createParameterResultCrossPlot();
|
||||
}
|
||||
|
||||
auto newPlot = correlationPlotColl->createParameterResultCrossPlot();
|
||||
newPlot->loadDataAndUpdate();
|
||||
|
||||
correlationPlotColl->updateConnectedEditors();
|
||||
|
@ -80,12 +80,20 @@ void RimAbstractCorrelationPlot::setCurveDefinitions( const std::vector<RiaSumma
|
||||
m_analysisPlotDataSelection.push_back( dataEntry );
|
||||
}
|
||||
auto timeSteps = allAvailableTimeSteps();
|
||||
if ( !timeSteps.empty() )
|
||||
if ( m_timeStep().isNull() && !timeSteps.empty() )
|
||||
{
|
||||
m_timeStep = QDateTime::fromTime_t( *timeSteps.rbegin() );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimAbstractCorrelationPlot::setTimeStep( std::time_t timeStep )
|
||||
{
|
||||
m_timeStep = QDateTime::fromTime_t( timeStep );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -27,6 +27,8 @@
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include <ctime>
|
||||
|
||||
class RiaSummaryCurveDefinition;
|
||||
class RiaSummaryCurveDefinitionAnalyser;
|
||||
class RimAnalysisPlotDataEntry;
|
||||
@ -43,6 +45,7 @@ public:
|
||||
public:
|
||||
std::vector<RiaSummaryCurveDefinition> curveDefinitions() const;
|
||||
void setCurveDefinitions( const std::vector<RiaSummaryCurveDefinition>& curveDefinitions );
|
||||
void setTimeStep( std::time_t timeStep );
|
||||
std::set<RimSummaryCaseCollection*> ensembles();
|
||||
RiuQwtPlotWidget* viewer() override;
|
||||
void detachAllCurves() override;
|
||||
|
@ -64,6 +64,24 @@ RimCorrelationPlot* RimCorrelationPlotCollection::createCorrelationPlot( bool de
|
||||
return plot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimCorrelationPlot* RimCorrelationPlotCollection::createCorrelationPlot( RimSummaryCaseCollection* ensemble,
|
||||
const QString& quantityName,
|
||||
std::time_t timeStep )
|
||||
{
|
||||
RimCorrelationPlot* plot = new RimCorrelationPlot();
|
||||
plot->setAsPlotMdiWindow();
|
||||
|
||||
applyEnsembleFieldAndTimeStepToPlot( plot, ensemble, quantityName.toStdString(), timeStep );
|
||||
plot->selectAllParameters();
|
||||
|
||||
m_correlationPlots.push_back( plot );
|
||||
|
||||
return plot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -79,6 +97,22 @@ RimCorrelationMatrixPlot* RimCorrelationPlotCollection::createCorrelationMatrixP
|
||||
return plot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimCorrelationMatrixPlot* RimCorrelationPlotCollection::createCorrelationMatrixPlot( RimSummaryCaseCollection* ensemble,
|
||||
std::time_t timeStep )
|
||||
{
|
||||
RimCorrelationMatrixPlot* plot = new RimCorrelationMatrixPlot();
|
||||
plot->setAsPlotMdiWindow();
|
||||
applyEnsembleFieldAndTimeStepToPlot( plot, ensemble, "", timeStep );
|
||||
plot->selectAllParameters();
|
||||
|
||||
m_correlationPlots.push_back( plot );
|
||||
|
||||
return plot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -92,6 +126,23 @@ RimParameterResultCrossPlot* RimCorrelationPlotCollection::createParameterResult
|
||||
return plot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimParameterResultCrossPlot* RimCorrelationPlotCollection::createParameterResultCrossPlot( RimSummaryCaseCollection* ensemble,
|
||||
const QString& paramName,
|
||||
const QString& quantityName,
|
||||
std::time_t timeStep )
|
||||
{
|
||||
RimParameterResultCrossPlot* plot = new RimParameterResultCrossPlot;
|
||||
plot->setAsPlotMdiWindow();
|
||||
applyEnsembleFieldAndTimeStepToPlot( plot, ensemble, quantityName.toStdString(), timeStep );
|
||||
plot->setEnsembleParameter( paramName );
|
||||
|
||||
m_correlationPlots.push_back( plot );
|
||||
return plot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -102,6 +153,23 @@ RimCorrelationReportPlot*
|
||||
report->setAsPlotMdiWindow();
|
||||
if ( defaultToFirstEnsembleFopt ) applyFirstEnsembleFieldAddressesToReport( report, "FOPT" );
|
||||
report->matrixPlot()->selectAllParameters();
|
||||
report->correlationPlot()->selectAllParameters();
|
||||
m_correlationReports.push_back( report );
|
||||
return report;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimCorrelationReportPlot* RimCorrelationPlotCollection::createCorrelationReportPlot( RimSummaryCaseCollection* ensemble,
|
||||
const QString& quantityName,
|
||||
std::time_t timeStep )
|
||||
{
|
||||
RimCorrelationReportPlot* report = new RimCorrelationReportPlot;
|
||||
report->setAsPlotMdiWindow();
|
||||
applyEnsembleFieldAndTimeStepToReport( report, ensemble, quantityName.toStdString(), timeStep );
|
||||
report->matrixPlot()->selectAllParameters();
|
||||
report->correlationPlot()->selectAllParameters();
|
||||
m_correlationReports.push_back( report );
|
||||
return report;
|
||||
}
|
||||
@ -171,6 +239,33 @@ void RimCorrelationPlotCollection::applyFirstEnsembleFieldAddressesToPlot( RimAb
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCorrelationPlotCollection::applyEnsembleFieldAndTimeStepToPlot( RimAbstractCorrelationPlot* 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() )
|
||||
{
|
||||
curveDefs.push_back( RiaSummaryCurveDefinition( nullptr, address, ensemble ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
plot->setCurveDefinitions( curveDefs );
|
||||
plot->setTimeStep( timeStep );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -199,6 +294,40 @@ void RimCorrelationPlotCollection::applyFirstEnsembleFieldAddressesToReport( Rim
|
||||
plot->matrixPlot()->setCurveDefinitions( curveDefsMatrix );
|
||||
plot->correlationPlot()->setCurveDefinitions( curveDefsTornadoAndCrossPlot );
|
||||
plot->crossPlot()->setCurveDefinitions( curveDefsTornadoAndCrossPlot );
|
||||
plot->crossPlot()->setEnsembleParameter( ensembles.front()->alphabeticEnsembleParameters().front().name );
|
||||
plot->crossPlot()->setEnsembleParameter( ensembles.front()->variationSortedEnsembleParameters().front().name );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCorrelationPlotCollection::applyEnsembleFieldAndTimeStepToReport( RimCorrelationReportPlot* plot,
|
||||
RimSummaryCaseCollection* ensemble,
|
||||
const std::string& quantityName,
|
||||
std::time_t timeStep )
|
||||
{
|
||||
if ( ensemble )
|
||||
{
|
||||
std::set<RifEclipseSummaryAddress> allAddresses = ensemble->ensembleSummaryAddresses();
|
||||
std::vector<RiaSummaryCurveDefinition> curveDefsMatrix;
|
||||
std::vector<RiaSummaryCurveDefinition> curveDefsTornadoAndCrossPlot;
|
||||
for ( auto address : allAddresses )
|
||||
{
|
||||
if ( address.category() == RifEclipseSummaryAddress::SUMMARY_FIELD )
|
||||
{
|
||||
curveDefsMatrix.push_back( RiaSummaryCurveDefinition( nullptr, address, ensemble ) );
|
||||
if ( quantityName.empty() || quantityName == address.quantityName() )
|
||||
{
|
||||
curveDefsTornadoAndCrossPlot.push_back( RiaSummaryCurveDefinition( nullptr, address, ensemble ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
plot->matrixPlot()->setCurveDefinitions( curveDefsMatrix );
|
||||
plot->matrixPlot()->setTimeStep( timeStep );
|
||||
plot->correlationPlot()->setCurveDefinitions( curveDefsTornadoAndCrossPlot );
|
||||
plot->correlationPlot()->setTimeStep( timeStep );
|
||||
plot->crossPlot()->setCurveDefinitions( curveDefsTornadoAndCrossPlot );
|
||||
plot->crossPlot()->setTimeStep( timeStep );
|
||||
plot->crossPlot()->setEnsembleParameter( ensemble->variationSortedEnsembleParameters().front().name );
|
||||
}
|
||||
}
|
||||
|
@ -21,11 +21,14 @@
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
#include <ctime>
|
||||
|
||||
class RimAbstractCorrelationPlot;
|
||||
class RimCorrelationPlot;
|
||||
class RimCorrelationMatrixPlot;
|
||||
class RimCorrelationReportPlot;
|
||||
class RimParameterResultCrossPlot;
|
||||
class RimSummaryCaseCollection;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -39,12 +42,26 @@ public:
|
||||
RimCorrelationPlotCollection();
|
||||
~RimCorrelationPlotCollection() override;
|
||||
|
||||
RimCorrelationPlot* createCorrelationPlot( bool defaultToFirstEnsembleFopt = true );
|
||||
RimCorrelationMatrixPlot* createCorrelationMatrixPlot( bool defaultToFirstEnsembleField = true );
|
||||
RimCorrelationPlot* createCorrelationPlot( bool defaultToFirstEnsembleFopt = true );
|
||||
RimCorrelationPlot*
|
||||
createCorrelationPlot( RimSummaryCaseCollection* ensemble, const QString& quantityName, std::time_t timeStep );
|
||||
|
||||
RimCorrelationMatrixPlot* createCorrelationMatrixPlot( bool defaultToFirstEnsembleField = true );
|
||||
RimCorrelationMatrixPlot* createCorrelationMatrixPlot( RimSummaryCaseCollection* ensemble, std::time_t timeStep );
|
||||
|
||||
RimParameterResultCrossPlot* createParameterResultCrossPlot( bool defaultToFirstEnsembleFopt = true );
|
||||
RimCorrelationReportPlot* createCorrelationReportPlot( bool defaultToFirstEnsembleFopt = true );
|
||||
void removePlot( RimAbstractCorrelationPlot* correlationPlot );
|
||||
void removeReport( RimCorrelationReportPlot* correlationReport );
|
||||
RimParameterResultCrossPlot* createParameterResultCrossPlot( RimSummaryCaseCollection* ensemble,
|
||||
const QString& paramName,
|
||||
const QString& quantityName,
|
||||
std::time_t timeStep );
|
||||
|
||||
RimCorrelationReportPlot* createCorrelationReportPlot( bool defaultToFirstEnsembleFopt = true );
|
||||
RimCorrelationReportPlot* createCorrelationReportPlot( RimSummaryCaseCollection* ensemble,
|
||||
const QString& quantityName,
|
||||
std::time_t timeStep );
|
||||
|
||||
void removePlot( RimAbstractCorrelationPlot* correlationPlot );
|
||||
void removeReport( RimCorrelationReportPlot* correlationReport );
|
||||
|
||||
std::vector<RimAbstractCorrelationPlot*> plots();
|
||||
std::vector<RimCorrelationReportPlot*> reports();
|
||||
@ -53,7 +70,15 @@ public:
|
||||
|
||||
private:
|
||||
void applyFirstEnsembleFieldAddressesToPlot( RimAbstractCorrelationPlot* plot, const std::string& quantityName = "" );
|
||||
void applyEnsembleFieldAndTimeStepToPlot( RimAbstractCorrelationPlot* plot,
|
||||
RimSummaryCaseCollection* ensemble,
|
||||
const std::string& quantityName,
|
||||
std::time_t timeStep );
|
||||
void applyFirstEnsembleFieldAddressesToReport( RimCorrelationReportPlot* plot, const std::string& quantityName = "" );
|
||||
void applyEnsembleFieldAndTimeStepToReport( RimCorrelationReportPlot* plot,
|
||||
RimSummaryCaseCollection* ensemble,
|
||||
const std::string& quantityName,
|
||||
std::time_t timeStep );
|
||||
|
||||
private:
|
||||
caf::PdmChildArrayField<RimAbstractCorrelationPlot*> m_correlationPlots;
|
||||
|
@ -63,7 +63,7 @@
|
||||
#include <QWheelEvent>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cfloat>
|
||||
#include <limits>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@ -968,7 +968,7 @@ void RiuQwtPlotWidget::findClosestPlotItem( const QPoint& pos,
|
||||
// Force empty defaults
|
||||
*closestItem = nullptr;
|
||||
*closestCurvePoint = -1;
|
||||
*distanceFromClick = DBL_MAX;
|
||||
*distanceFromClick = std::numeric_limits<double>::infinity();
|
||||
|
||||
const QwtPlotItemList& itmList = itemList();
|
||||
for ( QwtPlotItemIterator it = itmList.begin(); it != itmList.end(); it++ )
|
||||
@ -976,7 +976,7 @@ void RiuQwtPlotWidget::findClosestPlotItem( const QPoint& pos,
|
||||
if ( ( *it )->rtti() == QwtPlotItem::Rtti_PlotCurve )
|
||||
{
|
||||
QwtPlotCurve* candidateCurve = static_cast<QwtPlotCurve*>( *it );
|
||||
double dist = DBL_MAX;
|
||||
double dist = std::numeric_limits<double>::infinity();
|
||||
int curvePoint = candidateCurve->closestPoint( pos, &dist );
|
||||
if ( dist < *distanceFromClick )
|
||||
{
|
||||
@ -1023,7 +1023,7 @@ void RiuQwtPlotWidget::findClosestPlotItem( const QPoint& pos,
|
||||
void RiuQwtPlotWidget::selectClosestPlotItem( const QPoint& pos, bool toggleItemInSelection /*= false*/ )
|
||||
{
|
||||
QwtPlotItem* closestItem = nullptr;
|
||||
double distanceFromClick = DBL_MAX;
|
||||
double distanceFromClick = std::numeric_limits<double>::infinity();
|
||||
int closestCurvePoint = -1;
|
||||
|
||||
findClosestPlotItem( pos, &closestItem, &closestCurvePoint, &distanceFromClick );
|
||||
|
@ -161,12 +161,12 @@ protected:
|
||||
virtual bool isZoomerActive() const;
|
||||
virtual void endZoomOperations();
|
||||
|
||||
private:
|
||||
void findClosestPlotItem( const QPoint& pos,
|
||||
QwtPlotItem** closestItem,
|
||||
int* closestCurvePoint,
|
||||
double* distanceFromClick ) const;
|
||||
|
||||
private:
|
||||
void selectClosestPlotItem( const QPoint& pos, bool toggleItemInSelection = false );
|
||||
static int defaultMinimumWidth();
|
||||
void replot() override;
|
||||
|
@ -20,12 +20,16 @@
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
#include "Commands/CorrelationPlotCommands/RicNewCorrelationPlotFeature.h"
|
||||
|
||||
#include "RimEnsembleCurveSet.h"
|
||||
#include "RimEnsembleCurveSetCollection.h"
|
||||
#include "RimEnsembleStatisticsCase.h"
|
||||
#include "RimMainPlotCollection.h"
|
||||
#include "RimPlot.h"
|
||||
#include "RimRegularLegendConfig.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryCaseCollection.h"
|
||||
#include "RimSummaryCurve.h"
|
||||
#include "RimSummaryCurveCollection.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
@ -46,6 +50,7 @@
|
||||
#include "RimProject.h"
|
||||
|
||||
#include "cafCmdFeatureMenuBuilder.h"
|
||||
#include "cafIconProvider.h"
|
||||
#include "cafSelectionManager.h"
|
||||
#include "cafTitledOverlayFrame.h"
|
||||
|
||||
@ -66,6 +71,8 @@
|
||||
#include <QMouseEvent>
|
||||
#include <QWheelEvent>
|
||||
|
||||
#include <limits>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -176,6 +183,73 @@ void RiuSummaryQwtPlot::contextMenuEvent( QContextMenuEvent* event )
|
||||
menuBuilder << "RicShowPlotDataFeature";
|
||||
menuBuilder << "RicSavePlotTemplateFeature";
|
||||
|
||||
QwtPlotItem* closestItem = nullptr;
|
||||
double distanceFromClick = std::numeric_limits<double>::infinity();
|
||||
int closestCurvePoint = -1;
|
||||
QPoint globalPos = event->globalPos();
|
||||
QPoint localPos = this->canvas()->mapFromGlobal( globalPos );
|
||||
|
||||
findClosestPlotItem( localPos, &closestItem, &closestCurvePoint, &distanceFromClick );
|
||||
if ( closestItem && closestCurvePoint >= 0 )
|
||||
{
|
||||
RiuRimQwtPlotCurve* plotCurve = dynamic_cast<RiuRimQwtPlotCurve*>( closestItem );
|
||||
if ( plotCurve )
|
||||
{
|
||||
RimSummaryCurve* summaryCurve = dynamic_cast<RimSummaryCurve*>( plotCurve->ownerRimCurve() );
|
||||
if ( summaryCurve && closestCurvePoint < (int)summaryCurve->timeStepsY().size() )
|
||||
{
|
||||
std::time_t timeStep = summaryCurve->timeStepsY()[closestCurvePoint];
|
||||
|
||||
RimEnsembleCurveSet* ensembleCurveSet = nullptr;
|
||||
summaryCurve->firstAncestorOrThisOfType( ensembleCurveSet );
|
||||
|
||||
if ( ensembleCurveSet )
|
||||
{
|
||||
RimSummaryCaseCollection* ensemble = ensembleCurveSet->summaryCaseCollection();
|
||||
if ( ensemble && ensemble->isEnsemble() )
|
||||
{
|
||||
CorrelationPlotParams params( ensemble,
|
||||
QString::fromStdString(
|
||||
ensembleCurveSet->summaryAddress().quantityName() ),
|
||||
timeStep );
|
||||
QVariant variant = QVariant::fromValue( params );
|
||||
menuBuilder.subMenuStart( "Create Correlation Plot From Curve Point",
|
||||
*caf::IconProvider( ":/CorrelationPlots16x16.png" ).icon() );
|
||||
{
|
||||
menuBuilder.addCmdFeatureWithUserData( "RicNewCorrelationPlotFeature",
|
||||
"New Tornado Plot",
|
||||
variant );
|
||||
menuBuilder.addCmdFeatureWithUserData( "RicNewCorrelationMatrixPlotFeature",
|
||||
"New Matrix Plot",
|
||||
variant );
|
||||
menuBuilder.addCmdFeatureWithUserData( "RicNewCorrelationReportPlotFeature",
|
||||
"New Report Plot",
|
||||
variant );
|
||||
menuBuilder.subMenuStart( "Cross Plots",
|
||||
*caf::IconProvider( ":/CorrelationCrossPlot16x16.png" ).icon() );
|
||||
std::vector<EnsembleParameter> ensembleParameters =
|
||||
ensemble->variationSortedEnsembleParameters();
|
||||
for ( const EnsembleParameter& param : ensembleParameters )
|
||||
{
|
||||
if ( param.variationBin >= (int)EnsembleParameter::LOW_VARIATION )
|
||||
{
|
||||
params.ensembleParameter = param.name;
|
||||
variant = QVariant::fromValue( params );
|
||||
menuBuilder.addCmdFeatureWithUserData( "RicNewParameterResultCrossPlotFeature",
|
||||
QString( "New Cross Plot Against %1" )
|
||||
.arg( param.uiName() ),
|
||||
variant );
|
||||
}
|
||||
}
|
||||
menuBuilder.subMenuEnd();
|
||||
}
|
||||
menuBuilder.subMenuEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
menuBuilder.appendToMenu( &menu );
|
||||
|
||||
if ( menu.actions().size() > 0 )
|
||||
|
Loading…
Reference in New Issue
Block a user