Merge pull request #8754 from OPM/multiplot_improvements

Summary Multiplot: add new plot from a single curve in an ensemble plot and improve general plot performance
This commit is contained in:
jonjenssen
2022-03-31 12:34:07 +02:00
committed by GitHub
parent 2eb1713866
commit ebba37a623
15 changed files with 227 additions and 39 deletions

View File

@@ -4,6 +4,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryMultiPlotFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryPlotFromDataVectorFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryMultiPlotFromDataVectorFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryPlotFromCurveFeature.h
)
set(SOURCE_GROUP_SOURCE_FILES
@@ -12,6 +13,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryMultiPlotFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryPlotFromDataVectorFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryMultiPlotFromDataVectorFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryPlotFromCurveFeature.cpp
)
list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})

View File

@@ -0,0 +1,67 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2022 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 "RicNewSummaryPlotFromCurveFeature.h"
#include "RimSummaryCurve.h"
#include "RimSummaryPlot.h"
#include "RicSummaryPlotBuilder.h"
#include <QAction>
#include <QVariant>
CAF_CMD_SOURCE_INIT( RicNewSummaryPlotFromCurveFeature, "RicNewSummaryPlotFromCurveFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewSummaryPlotFromCurveFeature::isCommandEnabled()
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewSummaryPlotFromCurveFeature::onActionTriggered( bool isChecked )
{
QVariant userData = this->userData();
if ( !userData.isNull() && userData.canConvert<void*>() )
{
RimSummaryCurve* curve = static_cast<RimSummaryCurve*>( userData.value<void*>() );
auto curveCopy =
dynamic_cast<RimSummaryCurve*>( curve->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
RimSummaryPlot* plot = RicSummaryPlotBuilder::createPlot( { curveCopy } );
std::vector<RimSummaryPlot*> plots = { plot };
RicSummaryPlotBuilder::createAndAppendSummaryMultiPlot( plots );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewSummaryPlotFromCurveFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "New Summary Plot from Curve" );
actionToSetup->setIcon( QIcon( ":/SummaryPlotLight16x16.png" ) );
}

View File

@@ -0,0 +1,37 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2022 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RicfCommandObject.h"
#include "cafCmdFeature.h"
//==================================================================================================
///
//==================================================================================================
class RicNewSummaryPlotFromCurveFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -30,7 +30,6 @@ class RicNewSummaryPlotFromDataVectorFeature : public caf::CmdFeature
CAF_CMD_HEADER_INIT;
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;

View File

@@ -472,6 +472,24 @@ void RicSummaryPlotBuilder::appendPlotsToSummaryMultiPlot( RimSummaryMultiPlot*
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryPlot* RicSummaryPlotBuilder::createPlot( const std::vector<RimSummaryCurve*>& summaryCurves )
{
auto* plot = new RimSummaryPlot();
plot->enableAutoPlotTitle( true );
for ( auto& curve : summaryCurves )
{
plot->addCurveNoUpdate( curve );
}
plot->applyDefaultCurveAppearances();
return plot;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -83,6 +83,8 @@ public:
static RimSummaryMultiPlot* createAndAppendSummaryMultiPlot( const std::vector<caf::PdmObjectHandle*>& objects );
static void appendPlotsToSummaryMultiPlot( RimSummaryMultiPlot* multiPlot, const std::vector<RimSummaryPlot*>& plots );
static RimSummaryPlot* createPlot( const std::vector<RimSummaryCurve*>& summaryCurves );
static RimSummaryPlot* createPlot( const std::set<RifEclipseSummaryAddress>& addresses,
const std::vector<RimSummaryCase*>& summaryCases,
const std::vector<RimSummaryCaseCollection*>& ensembles );