Summary multiplot improvements (#8598)

* Create multi summary plot from summary plot(s)
* Rearrange multi summary plot properties
* Enable source stepping toolbar for multi summary plot
* Automatically activate new summary plot when creating from data sources -> data vector tree
* Enable global key controls for switching data in summary and multi summary plots
* Update tooltip texts for summary plot toolbar
This commit is contained in:
jonjenssen
2022-03-04 10:52:17 +01:00
committed by GitHub
parent a32dda2e65
commit abff06d2d5
35 changed files with 793 additions and 422 deletions
@@ -3,6 +3,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicSummaryPlotBuilder.h
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryMultiPlotFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryPlotFromDataVectorFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryMultiPlotFromDataVectorFeature.h
)
set(SOURCE_GROUP_SOURCE_FILES
@@ -10,6 +11,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicSummaryPlotBuilder.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryMultiPlotFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryPlotFromDataVectorFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryMultiPlotFromDataVectorFeature.cpp
)
list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021 Equinor ASA
// 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
@@ -19,8 +19,10 @@
#include "RicNewSummaryMultiPlotFeature.h"
#include "RimMultiPlotCollection.h"
#include "RimPlot.h"
#include "RimSummaryMultiPlot.h"
#include "RimSummaryPlot.h"
#include "RicSummaryPlotBuilder.h"
#include "cafSelectionManager.h"
#include "cvfAssert.h"
@@ -34,17 +36,7 @@ RICF_SOURCE_INIT( RicNewSummaryMultiPlotFeature, "RicNewSummaryMultiPlotFeature"
//--------------------------------------------------------------------------------------------------
RicNewSummaryMultiPlotFeature::RicNewSummaryMultiPlotFeature()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmScriptResponse RicNewSummaryMultiPlotFeature::execute()
{
std::vector<RimSummaryPlot*> plots;
RimSummaryMultiPlot::createAndAppendMultiPlot( plots );
return caf::PdmScriptResponse();
CAF_PDM_InitFieldNoDefault( &m_plots, "plots", "Plots" );
}
//--------------------------------------------------------------------------------------------------
@@ -52,16 +44,12 @@ caf::PdmScriptResponse RicNewSummaryMultiPlotFeature::execute()
//--------------------------------------------------------------------------------------------------
bool RicNewSummaryMultiPlotFeature::isCommandEnabled()
{
RimMultiPlotCollection* objToFind = nullptr;
auto plots = selectedPlots();
auto pdmUiItem = caf::SelectionManager::instance()->selectedItem();
auto objHandle = dynamic_cast<caf::PdmObjectHandle*>( pdmUiItem );
if ( objHandle )
{
objHandle->firstAncestorOrThisOfType( objToFind );
}
std::vector<caf::PdmUiItem*> selectedUiItems;
caf::SelectionManager::instance()->selectedItems( selectedUiItems );
return ( objToFind != nullptr );
return !plots.empty() && plots.size() == selectedUiItems.size();
}
//--------------------------------------------------------------------------------------------------
@@ -69,6 +57,12 @@ bool RicNewSummaryMultiPlotFeature::isCommandEnabled()
//--------------------------------------------------------------------------------------------------
void RicNewSummaryMultiPlotFeature::onActionTriggered( bool isChecked )
{
m_plots.v().clear();
auto plots = selectedPlots();
for ( RimPlot* plot : plots )
{
m_plots.v().push_back( reinterpret_cast<uintptr_t>( plot ) );
}
execute();
}
@@ -77,6 +71,47 @@ void RicNewSummaryMultiPlotFeature::onActionTriggered( bool isChecked )
//--------------------------------------------------------------------------------------------------
void RicNewSummaryMultiPlotFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Create Summary Multi Plot" );
actionToSetup->setText( "Create Summary Multi Plot from Selected Plots" );
actionToSetup->setIcon( QIcon( ":/MultiPlot16x16.png" ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimSummaryPlot*> RicNewSummaryMultiPlotFeature::selectedPlots()
{
std::vector<caf::PdmUiItem*> uiItems;
caf::SelectionManager::instance()->selectedItems( uiItems );
std::vector<RimSummaryPlot*> plots;
for ( caf::PdmUiItem* uiItem : uiItems )
{
RimSummaryPlot* summaryPlot = dynamic_cast<RimSummaryPlot*>( uiItem );
if ( summaryPlot )
{
plots.push_back( summaryPlot );
}
}
return plots;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmScriptResponse RicNewSummaryMultiPlotFeature::execute()
{
if ( !m_plots().empty() )
{
std::vector<RimSummaryPlot*> plots;
for ( auto ptr : m_plots() )
{
plots.push_back( reinterpret_cast<RimSummaryPlot*>( ptr ) );
}
auto copyOfPlots = RicSummaryPlotBuilder::duplicateSummaryPlots( plots );
RicSummaryPlotBuilder::createAndAppendSummaryMultiPlot( copyOfPlots );
}
return caf::PdmScriptResponse();
}
@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021 Equinor ASA
// 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
@@ -25,7 +25,7 @@
#include <vector>
class RimPlot;
class RimSummaryPlot;
//==================================================================================================
///
@@ -43,4 +43,9 @@ protected:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
private:
static std::vector<RimSummaryPlot*> selectedPlots();
caf::PdmField<std::vector<uint64_t>> m_plots;
};
@@ -0,0 +1,115 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicNewSummaryMultiPlotFromDataVectorFeature.h"
#include "RiaSummaryTools.h"
#include "RimSummaryAddress.h"
#include "RimSummaryPlot.h"
#include "RimSummaryPlotCollection.h"
#include "RicSummaryPlotBuilder.h"
#include "RifEclipseSummaryAddress.h"
#include "cafSelectionManagerTools.h"
#include "cvfAssert.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicNewSummaryMultiPlotFromDataVectorFeature, "RicNewSummaryMultiPlotFromDataVectorFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewSummaryMultiPlotFromDataVectorFeature::isCommandEnabled()
{
std::vector<caf::PdmUiItem*> selectedItems;
caf::SelectionManager::instance()->selectedItems( selectedItems );
std::vector<RimSummaryAddress*> selectedAddressItems = caf::selectedObjectsByType<RimSummaryAddress*>();
unsigned int nEnsembles = 0;
for ( auto adr : selectedAddressItems )
{
if ( adr->isEnsemble() ) nEnsembles++;
}
bool bOk = ( selectedAddressItems.size() > 0 );
if ( nEnsembles > 0 )
{
bOk = bOk && ( nEnsembles == selectedItems.size() );
}
bOk = bOk && ( selectedAddressItems.size() == selectedItems.size() );
return bOk;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewSummaryMultiPlotFromDataVectorFeature::onActionTriggered( bool isChecked )
{
std::vector<RimSummaryAddress*> selectedAddressItems = caf::selectedObjectsByType<RimSummaryAddress*>();
std::set<int> caseIds;
std::set<int> ensembleIds;
std::vector<RimSummaryCase*> selectedCases;
std::set<RifEclipseSummaryAddress> eclipseAddresses;
std::vector<RimSummaryCaseCollection*> selectedEnsembles;
bool isEnsemble = false;
for ( auto adr : selectedAddressItems )
{
eclipseAddresses.insert( adr->address() );
caseIds.insert( adr->caseId() );
ensembleIds.insert( adr->ensembleId() );
isEnsemble = isEnsemble || adr->isEnsemble();
}
if ( isEnsemble )
{
for ( auto id : ensembleIds )
{
selectedEnsembles.push_back( RiaSummaryTools::ensembleById( id ) );
}
}
else
{
for ( auto id : caseIds )
{
selectedCases.push_back( RiaSummaryTools::summaryCaseById( id ) );
}
}
auto newPlot = RicSummaryPlotBuilder::createPlot( eclipseAddresses, selectedCases, selectedEnsembles );
std::vector<RimSummaryPlot*> plots{ newPlot };
RicSummaryPlotBuilder::createAndAppendSummaryMultiPlot( plots );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewSummaryMultiPlotFromDataVectorFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "New Multi Summary Plot" );
actionToSetup->setIcon( QIcon( ":/SummaryPlotLight16x16.png" ) );
}
@@ -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 RicNewSummaryMultiPlotFromDataVectorFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};
@@ -27,6 +27,8 @@
#include "RifEclipseSummaryAddress.h"
#include "RiuPlotMainWindowTools.h"
#include "cafSelectionManagerTools.h"
#include "cvfAssert.h"
@@ -108,6 +110,8 @@ void RicNewSummaryPlotFromDataVectorFeature::onActionTriggered( bool isChecked )
newPlot->loadDataAndUpdate();
plotCollection->updateConnectedEditors();
RiuPlotMainWindowTools::selectAsCurrentItem( newPlot, true );
}
//--------------------------------------------------------------------------------------------------
@@ -36,6 +36,8 @@
#include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h"
#include "RimSummaryCurve.h"
#include "RimSummaryMultiPlot.h"
#include "RimSummaryMultiPlotCollection.h"
#include "RimSummaryPlotCollection.h"
#include "RiuPlotMainWindowTools.h"
@@ -292,6 +294,27 @@ std::vector<RimPlot*> RicSummaryPlotBuilder::duplicatePlots( const std::vector<R
return plots;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimSummaryPlot*> RicSummaryPlotBuilder::duplicateSummaryPlots( const std::vector<RimSummaryPlot*>& sourcePlots )
{
std::vector<RimSummaryPlot*> plots;
for ( auto plot : sourcePlots )
{
auto copy =
dynamic_cast<RimSummaryPlot*>( plot->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
if ( copy )
{
plots.push_back( copy );
}
}
return plots;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -335,6 +358,49 @@ void RicSummaryPlotBuilder::appendPlotsToMultiPlot( RimMultiPlot* multiPlot, con
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryMultiPlot* RicSummaryPlotBuilder::createAndAppendSummaryMultiPlot( const std::vector<RimSummaryPlot*>& plots )
{
RimProject* project = RimProject::current();
auto* plotCollection = project->mainPlotCollection()->summaryMultiPlotCollection();
auto* plotWindow = new RimSummaryMultiPlot();
plotWindow->setMultiPlotTitle( QString( "Multi Summary Plot %1" ).arg( plotCollection->multiPlots().size() + 1 ) );
plotWindow->setAsPlotMdiWindow();
plotCollection->addMultiSummaryPlot( plotWindow );
appendPlotsToSummaryMultiPlot( plotWindow, plots );
plotCollection->updateAllRequiredEditors();
plotWindow->loadDataAndUpdate();
RiuPlotMainWindowTools::selectAsCurrentItem( plotWindow, true );
plotWindow->updateAllRequiredEditors();
return plotWindow;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSummaryPlotBuilder::appendPlotsToSummaryMultiPlot( RimSummaryMultiPlot* multiPlot,
const std::vector<RimSummaryPlot*>& plots )
{
for ( auto plot : plots )
{
plot->revokeMdiWindowStatus();
multiPlot->addPlot( plot );
plot->resolveReferencesRecursively();
plot->setShowWindow( true );
plot->loadDataAndUpdate();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -26,6 +26,7 @@ class RimSummaryCaseCollection;
class RimSummaryPlot;
class RimEnsembleCurveSet;
class RimSummaryCurve;
class RimSummaryMultiPlot;
namespace caf
{
@@ -67,9 +68,14 @@ public:
static RimEnsembleCurveSet* createCurveSet( RimSummaryCaseCollection* ensemble, const RifEclipseSummaryAddress& addr );
static RimSummaryCurve* createCurve( RimSummaryCase* summaryCase, const RifEclipseSummaryAddress& addr );
static std::vector<RimPlot*> duplicatePlots( const std::vector<RimPlot*>& plots );
static RimMultiPlot* createAndAppendMultiPlot( const std::vector<RimPlot*>& plots );
static void appendPlotsToMultiPlot( RimMultiPlot* multiPlot, const std::vector<RimPlot*>& plots );
static std::vector<RimPlot*> duplicatePlots( const std::vector<RimPlot*>& plots );
static std::vector<RimSummaryPlot*> duplicateSummaryPlots( const std::vector<RimSummaryPlot*>& plots );
static RimMultiPlot* createAndAppendMultiPlot( const std::vector<RimPlot*>& plots );
static void appendPlotsToMultiPlot( RimMultiPlot* multiPlot, const std::vector<RimPlot*>& plots );
static RimSummaryMultiPlot* createAndAppendSummaryMultiPlot( const std::vector<RimSummaryPlot*>& plots );
static void appendPlotsToSummaryMultiPlot( RimSummaryMultiPlot* multiPlot, const std::vector<RimSummaryPlot*>& plots );
static RimSummaryPlot* createPlot( const std::set<RifEclipseSummaryAddress>& addresses,
const std::vector<RimSummaryCase*>& summaryCases,