mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Split summary plot into multiple plots (#8910)
* Support splitting a summary plot with multiple curves into a new multiplot with one plot per curve * Make sure the correct plot is deleted if using the plot context menu.
This commit is contained in:
parent
6f26f8e462
commit
3b927e1c09
@ -11,6 +11,7 @@ set(SOURCE_GROUP_HEADER_FILES
|
|||||||
${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryCurvesForSummaryCasesFeature.h
|
${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryCurvesForSummaryCasesFeature.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryPlotsForSummaryAddressesFeature.h
|
${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryPlotsForSummaryAddressesFeature.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryCurvesForSummaryAddressesFeature.h
|
${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryCurvesForSummaryAddressesFeature.h
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RicSplitMultiPlotFeature.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(SOURCE_GROUP_SOURCE_FILES
|
set(SOURCE_GROUP_SOURCE_FILES
|
||||||
@ -26,6 +27,7 @@ set(SOURCE_GROUP_SOURCE_FILES
|
|||||||
${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryCurvesForSummaryCasesFeature.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryCurvesForSummaryCasesFeature.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryPlotsForSummaryAddressesFeature.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryPlotsForSummaryAddressesFeature.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryCurvesForSummaryAddressesFeature.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryCurvesForSummaryAddressesFeature.cpp
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RicSplitMultiPlotFeature.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
|
list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
|
||||||
|
@ -0,0 +1,117 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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 "RicSplitMultiPlotFeature.h"
|
||||||
|
|
||||||
|
#include "RicSummaryPlotBuilder.h"
|
||||||
|
|
||||||
|
#include "RimEnsembleCurveSet.h"
|
||||||
|
#include "RimSummaryAddress.h"
|
||||||
|
#include "RimSummaryCase.h"
|
||||||
|
#include "RimSummaryCurve.h"
|
||||||
|
#include "RimSummaryPlot.h"
|
||||||
|
|
||||||
|
#include "RicSummaryPlotBuilder.h"
|
||||||
|
|
||||||
|
#include "cafSelectionManager.h"
|
||||||
|
#include "cvfAssert.h"
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
|
|
||||||
|
CAF_CMD_SOURCE_INIT( RicSplitMultiPlotFeature, "RicSplitMultiPlotFeature" );
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RicSplitMultiPlotFeature::isCommandEnabled()
|
||||||
|
{
|
||||||
|
RimSummaryPlot* plot = getSelectedPlot();
|
||||||
|
if ( plot )
|
||||||
|
{
|
||||||
|
return ( ( plot->summaryCurves().size() > 1 ) || ( plot->curveSets().size() > 1 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicSplitMultiPlotFeature::onActionTriggered( bool isChecked )
|
||||||
|
{
|
||||||
|
RimSummaryPlot* plot = getSelectedPlot();
|
||||||
|
if ( plot == nullptr ) return;
|
||||||
|
|
||||||
|
std::vector<caf::PdmObjectHandle*> objects = {};
|
||||||
|
|
||||||
|
for ( auto curve : plot->summaryCurves() )
|
||||||
|
{
|
||||||
|
RimSummaryAddress* addr = RimSummaryAddress::wrapFileReaderAddress( curve->summaryAddressY() );
|
||||||
|
addr->setCaseId( curve->summaryCaseY()->caseId() );
|
||||||
|
objects.push_back( addr );
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( auto curveSet : plot->curveSets() )
|
||||||
|
{
|
||||||
|
RimSummaryAddress* addr = RimSummaryAddress::wrapFileReaderAddress( curveSet->summaryAddress() );
|
||||||
|
addr->setEnsembleId( curveSet->ensembleId() );
|
||||||
|
objects.push_back( addr );
|
||||||
|
}
|
||||||
|
|
||||||
|
RicSummaryPlotBuilder::createAndAppendSummaryMultiPlot( objects );
|
||||||
|
|
||||||
|
for ( auto object : objects )
|
||||||
|
delete object;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicSplitMultiPlotFeature::setupActionLook( QAction* actionToSetup )
|
||||||
|
{
|
||||||
|
actionToSetup->setText( "Split" );
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
RimSummaryPlot* RicSplitMultiPlotFeature::getSelectedPlot()
|
||||||
|
{
|
||||||
|
RimSummaryPlot* plot = nullptr;
|
||||||
|
|
||||||
|
if ( sender() )
|
||||||
|
{
|
||||||
|
QVariant userData = this->userData();
|
||||||
|
if ( !userData.isNull() && userData.canConvert<void*>() )
|
||||||
|
{
|
||||||
|
plot = static_cast<RimSummaryPlot*>( userData.value<void*>() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( plot == nullptr )
|
||||||
|
{
|
||||||
|
std::vector<caf::PdmUiItem*> selectedUiItems;
|
||||||
|
caf::SelectionManager::instance()->selectedItems( selectedUiItems );
|
||||||
|
|
||||||
|
if ( !selectedUiItems.empty() ) plot = dynamic_cast<RimSummaryPlot*>( selectedUiItems[0] );
|
||||||
|
}
|
||||||
|
|
||||||
|
return plot;
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// 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 "cafCmdFeature.h"
|
||||||
|
|
||||||
|
class RimSummaryPlot;
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
///
|
||||||
|
//==================================================================================================
|
||||||
|
class RicSplitMultiPlotFeature : public caf::CmdFeature
|
||||||
|
{
|
||||||
|
CAF_CMD_HEADER_INIT;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool isCommandEnabled() override;
|
||||||
|
void onActionTriggered( bool isChecked ) override;
|
||||||
|
void setupActionLook( QAction* actionToSetup ) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
RimSummaryPlot* getSelectedPlot();
|
||||||
|
};
|
@ -26,6 +26,7 @@
|
|||||||
#include "RiuQwtPlotWidget.h"
|
#include "RiuQwtPlotWidget.h"
|
||||||
|
|
||||||
#include "RimMultiPlot.h"
|
#include "RimMultiPlot.h"
|
||||||
|
#include "RimPlot.h"
|
||||||
#include "RimPlotWindow.h"
|
#include "RimPlotWindow.h"
|
||||||
#include "RimWellLogPlot.h"
|
#include "RimWellLogPlot.h"
|
||||||
#include "RimWellLogTrack.h"
|
#include "RimWellLogTrack.h"
|
||||||
@ -76,7 +77,8 @@ void RicDeleteSubPlotFeature::onActionTriggered( bool isChecked )
|
|||||||
if ( RicWellLogPlotCurveFeatureImpl::parentWellAllocationPlot() ) return;
|
if ( RicWellLogPlotCurveFeatureImpl::parentWellAllocationPlot() ) return;
|
||||||
|
|
||||||
std::vector<RimPlot*> selection;
|
std::vector<RimPlot*> selection;
|
||||||
caf::SelectionManager::instance()->objectsByType( &selection );
|
getSelection( selection );
|
||||||
|
|
||||||
std::set<RimMultiPlot*> alteredPlotWindows;
|
std::set<RimMultiPlot*> alteredPlotWindows;
|
||||||
|
|
||||||
for ( RimPlot* plot : selection )
|
for ( RimPlot* plot : selection )
|
||||||
@ -120,11 +122,11 @@ void RicDeleteSubPlotFeature::onActionTriggered( bool isChecked )
|
|||||||
void RicDeleteSubPlotFeature::setupActionLook( QAction* actionToSetup )
|
void RicDeleteSubPlotFeature::setupActionLook( QAction* actionToSetup )
|
||||||
{
|
{
|
||||||
QString actionText;
|
QString actionText;
|
||||||
std::vector<caf::PdmObject*> selection;
|
std::vector<RimPlot*> selection;
|
||||||
caf::SelectionManager::instance()->objectsByType( &selection );
|
getSelection( selection );
|
||||||
|
|
||||||
size_t tracksSelected = 0u;
|
size_t tracksSelected = 0u;
|
||||||
for ( caf::PdmObject* object : selection )
|
for ( RimPlot* object : selection )
|
||||||
{
|
{
|
||||||
if ( dynamic_cast<RimWellLogTrack*>( object ) )
|
if ( dynamic_cast<RimWellLogTrack*>( object ) )
|
||||||
{
|
{
|
||||||
@ -148,3 +150,24 @@ void RicDeleteSubPlotFeature::setupActionLook( QAction* actionToSetup )
|
|||||||
actionToSetup->setIcon( QIcon( ":/Erase.svg" ) );
|
actionToSetup->setIcon( QIcon( ":/Erase.svg" ) );
|
||||||
applyShortcutWithHintToAction( actionToSetup, QKeySequence::Delete );
|
applyShortcutWithHintToAction( actionToSetup, QKeySequence::Delete );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicDeleteSubPlotFeature::getSelection( std::vector<RimPlot*>& selection )
|
||||||
|
{
|
||||||
|
if ( sender() )
|
||||||
|
{
|
||||||
|
QVariant userData = this->userData();
|
||||||
|
if ( !userData.isNull() && userData.canConvert<void*>() )
|
||||||
|
{
|
||||||
|
RimPlot* plot = static_cast<RimPlot*>( userData.value<void*>() );
|
||||||
|
if ( plot ) selection.push_back( plot );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( selection.empty() )
|
||||||
|
{
|
||||||
|
caf::SelectionManager::instance()->objectsByType( &selection );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -21,6 +21,10 @@
|
|||||||
|
|
||||||
#include "cafCmdFeature.h"
|
#include "cafCmdFeature.h"
|
||||||
|
|
||||||
|
class RimPlot;
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
///
|
///
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
@ -32,4 +36,7 @@ protected:
|
|||||||
bool isCommandEnabled() override;
|
bool isCommandEnabled() override;
|
||||||
void onActionTriggered( bool isChecked ) override;
|
void onActionTriggered( bool isChecked ) override;
|
||||||
void setupActionLook( QAction* actionToSetup ) override;
|
void setupActionLook( QAction* actionToSetup ) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void getSelection( std::vector<RimPlot*>& selection );
|
||||||
};
|
};
|
||||||
|
@ -677,6 +677,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
|||||||
menuBuilder << "Separator";
|
menuBuilder << "Separator";
|
||||||
menuBuilder << "RicEditSummaryPlotFeature";
|
menuBuilder << "RicEditSummaryPlotFeature";
|
||||||
menuBuilder << "RicDuplicateSummaryPlotFeature";
|
menuBuilder << "RicDuplicateSummaryPlotFeature";
|
||||||
|
menuBuilder << "RicSplitMultiPlotFeature";
|
||||||
menuBuilder << "RicNewSummaryEnsembleCurveSetFeature";
|
menuBuilder << "RicNewSummaryEnsembleCurveSetFeature";
|
||||||
menuBuilder << "RicDuplicateSummaryCrossPlotFeature";
|
menuBuilder << "RicDuplicateSummaryCrossPlotFeature";
|
||||||
menuBuilder << "RicNewSummaryCrossPlotCurveFeature";
|
menuBuilder << "RicNewSummaryCrossPlotCurveFeature";
|
||||||
|
@ -2001,6 +2001,16 @@ void RimEnsembleCurveSet::updateEnsembleLegendItem()
|
|||||||
m_plotCurveForLegendText->setVisibleInLegend( showLegendItem );
|
m_plotCurveForLegendText->setVisibleInLegend( showLegendItem );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
int RimEnsembleCurveSet::ensembleId() const
|
||||||
|
{
|
||||||
|
if ( m_yValuesSummaryCaseCollection() != nullptr ) return m_yValuesSummaryCaseCollection()->ensembleId();
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -108,6 +108,8 @@ public:
|
|||||||
RifEclipseSummaryAddress summaryAddress() const;
|
RifEclipseSummaryAddress summaryAddress() const;
|
||||||
std::vector<RimSummaryCurve*> curves() const;
|
std::vector<RimSummaryCurve*> curves() const;
|
||||||
|
|
||||||
|
int ensembleId() const;
|
||||||
|
|
||||||
RimCustomObjectiveFunctionCollection* customObjectiveFunctionCollection();
|
RimCustomObjectiveFunctionCollection* customObjectiveFunctionCollection();
|
||||||
|
|
||||||
void deleteEnsembleCurves();
|
void deleteEnsembleCurves();
|
||||||
|
@ -193,7 +193,14 @@ void RiuSummaryPlot::showContextMenu( QPoint pos )
|
|||||||
}
|
}
|
||||||
|
|
||||||
menuBuilder.addSeparator();
|
menuBuilder.addSeparator();
|
||||||
menuBuilder << "RicDeleteSubPlotFeature";
|
|
||||||
|
RimSummaryPlot* plot = dynamic_cast<RimSummaryPlot*>( plotWidget()->plotDefinition() );
|
||||||
|
if ( plot )
|
||||||
|
{
|
||||||
|
QVariant plotVariant( QVariant::fromValue( static_cast<void*>( plot ) ) );
|
||||||
|
menuBuilder.addCmdFeatureWithUserData( "RicSplitMultiPlotFeature", "Split into Multiple Plots", plotVariant );
|
||||||
|
menuBuilder.addCmdFeatureWithUserData( "RicDeleteSubPlotFeature", "Delete Plot", plotVariant );
|
||||||
|
}
|
||||||
|
|
||||||
menuBuilder.appendToMenu( &menu );
|
menuBuilder.appendToMenu( &menu );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user