mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#5621 Delta case : Create delta case from two selected cases
This commit is contained in:
@@ -37,10 +37,9 @@ CAF_CMD_SOURCE_INIT( RicNewDerivedSummaryFeature, "RicNewDerivedSummaryFeature"
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicNewDerivedSummaryFeature::isCommandEnabled()
|
||||
{
|
||||
std::vector<RimSummaryCaseMainCollection*> mainColls =
|
||||
caf::selectedObjectsByTypeStrict<RimSummaryCaseMainCollection*>();
|
||||
if ( mainCollection() ) return true;
|
||||
|
||||
return mainColls.size() == 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -48,13 +47,20 @@ bool RicNewDerivedSummaryFeature::isCommandEnabled()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewDerivedSummaryFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
if ( isCommandEnabled() )
|
||||
auto mainColl = mainCollection();
|
||||
if ( mainColl )
|
||||
{
|
||||
auto project = RiaApplication::instance()->project();
|
||||
auto mainColl = project->firstSummaryCaseMainCollection();
|
||||
|
||||
auto derivedCase = new RimDerivedSummaryCase;
|
||||
|
||||
auto selectedCases = twoSelectedSummaryCases();
|
||||
if ( !selectedCases.empty() )
|
||||
{
|
||||
derivedCase->setSummaryCases( selectedCases[0], selectedCases[1] );
|
||||
derivedCase->createSummaryReaderInterface();
|
||||
}
|
||||
|
||||
mainColl->addCase( derivedCase );
|
||||
derivedCase->updateDisplayNameFromCases();
|
||||
|
||||
mainColl->updateConnectedEditors();
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem( derivedCase );
|
||||
@@ -69,3 +75,35 @@ void RicNewDerivedSummaryFeature::setupActionLook( QAction* actionToSetup )
|
||||
actionToSetup->setText( "New Delta Summary Case" );
|
||||
// actionToSetup->setIcon( QIcon( ":/SummaryEnsemble16x16.png" ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryCaseMainCollection* RicNewDerivedSummaryFeature::mainCollection()
|
||||
{
|
||||
std::vector<RimSummaryCaseMainCollection*> mainColls =
|
||||
caf::selectedObjectsByTypeStrict<RimSummaryCaseMainCollection*>();
|
||||
|
||||
if ( mainColls.size() == 1 ) return mainColls.front();
|
||||
|
||||
auto sumCases = twoSelectedSummaryCases();
|
||||
if ( !sumCases.empty() )
|
||||
{
|
||||
RimSummaryCaseMainCollection* mainColl = nullptr;
|
||||
sumCases.front()->firstAncestorOfType( mainColl );
|
||||
return mainColl;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimSummaryCase*> RicNewDerivedSummaryFeature::twoSelectedSummaryCases()
|
||||
{
|
||||
auto sumCases = caf::selectedObjectsByTypeStrict<RimSummaryCase*>();
|
||||
if ( sumCases.size() == 2 ) return sumCases;
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
class RimSummaryCase;
|
||||
class RimSummaryCaseMainCollection;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
@@ -32,4 +35,8 @@ protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
private:
|
||||
static RimSummaryCaseMainCollection* mainCollection();
|
||||
static std::vector<RimSummaryCase*> twoSelectedSummaryCases();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user