2020-04-17 02:31:42 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2020- Equinor ASA
|
|
|
|
//
|
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicNewCorrelationPlotFeature.h"
|
|
|
|
|
|
|
|
#include "RimCorrelationPlot.h"
|
|
|
|
#include "RimCorrelationPlotCollection.h"
|
2020-07-28 08:13:39 -05:00
|
|
|
#include "RimProject.h"
|
|
|
|
#include "RimSummaryPlot.h"
|
2020-04-17 02:31:42 -05:00
|
|
|
|
|
|
|
#include "RiuPlotMainWindowTools.h"
|
|
|
|
|
|
|
|
#include "cafSelectionManager.h"
|
2023-05-12 14:41:34 -05:00
|
|
|
#include "cafSelectionManagerTools.h"
|
2020-04-17 02:31:42 -05:00
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
|
|
|
CAF_CMD_SOURCE_INIT( RicNewCorrelationPlotFeature, "RicNewCorrelationPlotFeature" );
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-06-26 07:28:46 -05:00
|
|
|
bool RicNewCorrelationPlotFeature::isCommandEnabled() const
|
2020-04-17 02:31:42 -05:00
|
|
|
{
|
2023-05-12 14:41:34 -05:00
|
|
|
if ( caf::firstAncestorOfTypeFromSelectedObject<RimCorrelationPlotCollection>() ) return true;
|
|
|
|
if ( caf::firstAncestorOfTypeFromSelectedObject<RimSummaryPlot>() ) return true;
|
2020-07-28 08:13:39 -05:00
|
|
|
|
2020-04-17 02:31:42 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicNewCorrelationPlotFeature::onActionTriggered( bool isChecked )
|
|
|
|
{
|
2023-05-12 14:41:34 -05:00
|
|
|
RimCorrelationPlotCollection* correlationPlotColl = caf::firstAncestorOfTypeFromSelectedObject<RimCorrelationPlotCollection>();
|
2020-04-17 02:31:42 -05:00
|
|
|
|
2020-07-28 08:13:39 -05:00
|
|
|
RimCorrelationPlot* newPlot = nullptr;
|
|
|
|
if ( !correlationPlotColl )
|
|
|
|
{
|
|
|
|
QVariant userData = this->userData();
|
2020-07-31 05:51:36 -05:00
|
|
|
if ( !userData.isNull() && userData.canConvert<EnsemblePlotParams>() )
|
2020-07-28 08:13:39 -05:00
|
|
|
{
|
2023-05-12 14:41:34 -05:00
|
|
|
auto correlationPlotCollections = RimProject::current()->descendantsOfType<RimCorrelationPlotCollection>();
|
2020-07-28 08:13:39 -05:00
|
|
|
CAF_ASSERT( !correlationPlotCollections.empty() );
|
|
|
|
correlationPlotColl = correlationPlotCollections.front();
|
|
|
|
|
2020-10-09 06:43:31 -05:00
|
|
|
EnsemblePlotParams params = userData.value<EnsemblePlotParams>();
|
|
|
|
RimSummaryCaseCollection* ensemble = params.ensemble;
|
|
|
|
QString quantityName = params.mainQuantityName;
|
|
|
|
std::time_t timeStep = params.timeStep;
|
2020-07-28 08:13:39 -05:00
|
|
|
|
|
|
|
newPlot = correlationPlotColl->createCorrelationPlot( ensemble, quantityName, timeStep );
|
|
|
|
}
|
|
|
|
}
|
2021-04-05 11:18:34 -05:00
|
|
|
|
|
|
|
if ( !newPlot && correlationPlotColl )
|
2020-07-28 08:13:39 -05:00
|
|
|
{
|
|
|
|
newPlot = correlationPlotColl->createCorrelationPlot();
|
|
|
|
}
|
2020-04-17 02:31:42 -05:00
|
|
|
|
|
|
|
newPlot->loadDataAndUpdate();
|
|
|
|
|
2021-04-05 11:18:34 -05:00
|
|
|
if ( correlationPlotColl ) correlationPlotColl->updateConnectedEditors();
|
2020-04-17 02:31:42 -05:00
|
|
|
|
2022-08-18 05:37:51 -05:00
|
|
|
RiuPlotMainWindowTools::onObjectAppended( newPlot );
|
2020-04-17 02:31:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicNewCorrelationPlotFeature::setupActionLook( QAction* actionToSetup )
|
|
|
|
{
|
2020-06-05 05:59:09 -05:00
|
|
|
actionToSetup->setText( "New Correlation Tornado Plot" );
|
2020-06-08 03:49:34 -05:00
|
|
|
actionToSetup->setIcon( QIcon( ":/CorrelationTornadoPlot16x16.png" ) );
|
2020-04-17 02:31:42 -05:00
|
|
|
}
|
2020-07-28 08:13:39 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-07-31 05:51:36 -05:00
|
|
|
EnsemblePlotParams::EnsemblePlotParams()
|
2020-07-28 08:13:39 -05:00
|
|
|
: ensemble( nullptr )
|
2020-08-25 06:56:46 -05:00
|
|
|
, mainQuantityName( "" )
|
2020-07-28 08:13:39 -05:00
|
|
|
, ensembleParameter( "" )
|
|
|
|
, timeStep( 0 )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-07-31 05:51:36 -05:00
|
|
|
EnsemblePlotParams::EnsemblePlotParams( RimSummaryCaseCollection* ensemble,
|
2020-08-25 06:56:46 -05:00
|
|
|
const QStringList& includedQuantityNames,
|
|
|
|
const QString& mainQuantityName,
|
2020-07-31 05:51:36 -05:00
|
|
|
const std::time_t& timeStep )
|
2020-07-28 08:13:39 -05:00
|
|
|
: ensemble( ensemble )
|
2020-08-25 06:56:46 -05:00
|
|
|
, includedQuantityNames( includedQuantityNames )
|
|
|
|
, mainQuantityName( mainQuantityName )
|
2020-07-28 08:13:39 -05:00
|
|
|
, ensembleParameter( "" )
|
|
|
|
, timeStep( timeStep )
|
|
|
|
{
|
|
|
|
}
|