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:
parent
b01d826acf
commit
9ef51a5e98
@ -37,10 +37,9 @@ CAF_CMD_SOURCE_INIT( RicNewDerivedSummaryFeature, "RicNewDerivedSummaryFeature"
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
bool RicNewDerivedSummaryFeature::isCommandEnabled()
|
bool RicNewDerivedSummaryFeature::isCommandEnabled()
|
||||||
{
|
{
|
||||||
std::vector<RimSummaryCaseMainCollection*> mainColls =
|
if ( mainCollection() ) return true;
|
||||||
caf::selectedObjectsByTypeStrict<RimSummaryCaseMainCollection*>();
|
|
||||||
|
|
||||||
return mainColls.size() == 1;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -48,13 +47,20 @@ bool RicNewDerivedSummaryFeature::isCommandEnabled()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RicNewDerivedSummaryFeature::onActionTriggered( bool isChecked )
|
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 derivedCase = new RimDerivedSummaryCase;
|
||||||
|
|
||||||
|
auto selectedCases = twoSelectedSummaryCases();
|
||||||
|
if ( !selectedCases.empty() )
|
||||||
|
{
|
||||||
|
derivedCase->setSummaryCases( selectedCases[0], selectedCases[1] );
|
||||||
|
derivedCase->createSummaryReaderInterface();
|
||||||
|
}
|
||||||
|
|
||||||
mainColl->addCase( derivedCase );
|
mainColl->addCase( derivedCase );
|
||||||
|
derivedCase->updateDisplayNameFromCases();
|
||||||
|
|
||||||
mainColl->updateConnectedEditors();
|
mainColl->updateConnectedEditors();
|
||||||
RiuPlotMainWindowTools::selectAsCurrentItem( derivedCase );
|
RiuPlotMainWindowTools::selectAsCurrentItem( derivedCase );
|
||||||
@ -69,3 +75,35 @@ void RicNewDerivedSummaryFeature::setupActionLook( QAction* actionToSetup )
|
|||||||
actionToSetup->setText( "New Delta Summary Case" );
|
actionToSetup->setText( "New Delta Summary Case" );
|
||||||
// actionToSetup->setIcon( QIcon( ":/SummaryEnsemble16x16.png" ) );
|
// 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"
|
#include "cafCmdFeature.h"
|
||||||
|
|
||||||
|
class RimSummaryCase;
|
||||||
|
class RimSummaryCaseMainCollection;
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
///
|
///
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
@ -32,4 +35,8 @@ 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:
|
||||||
|
static RimSummaryCaseMainCollection* mainCollection();
|
||||||
|
static std::vector<RimSummaryCase*> twoSelectedSummaryCases();
|
||||||
};
|
};
|
||||||
|
@ -876,6 +876,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
|||||||
menuBuilder << "RicNewDefaultSummaryPlotFeature";
|
menuBuilder << "RicNewDefaultSummaryPlotFeature";
|
||||||
menuBuilder << "RicNewSummaryCrossPlotFeature";
|
menuBuilder << "RicNewSummaryCrossPlotFeature";
|
||||||
menuBuilder << "RicSummaryCurveSwitchAxisFeature";
|
menuBuilder << "RicSummaryCurveSwitchAxisFeature";
|
||||||
|
menuBuilder << "RicNewDerivedSummaryFeature";
|
||||||
menuBuilder.addSeparator();
|
menuBuilder.addSeparator();
|
||||||
menuBuilder << "RicConvertGroupToEnsembleFeature";
|
menuBuilder << "RicConvertGroupToEnsembleFeature";
|
||||||
menuBuilder.addSeparator();
|
menuBuilder.addSeparator();
|
||||||
|
@ -283,7 +283,7 @@ void RimDerivedSummaryCase::clearData( const RifEclipseSummaryAddress& address )
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimDerivedSummaryCase::updateNameFromInputCases()
|
void RimDerivedSummaryCase::updateDisplayNameFromCases()
|
||||||
{
|
{
|
||||||
QString case1Name = "None";
|
QString case1Name = "None";
|
||||||
QString case2Name = "None";
|
QString case2Name = "None";
|
||||||
@ -370,7 +370,7 @@ void RimDerivedSummaryCase::fieldChangedByUi( const caf::PdmFieldHandle* changed
|
|||||||
|
|
||||||
if ( reloadData )
|
if ( reloadData )
|
||||||
{
|
{
|
||||||
updateNameFromInputCases();
|
updateDisplayNameFromCases();
|
||||||
|
|
||||||
m_dataCache.clear();
|
m_dataCache.clear();
|
||||||
|
|
||||||
|
@ -64,6 +64,8 @@ public:
|
|||||||
RifSummaryReaderInterface* summaryReader() override;
|
RifSummaryReaderInterface* summaryReader() override;
|
||||||
void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) override;
|
void updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath ) override;
|
||||||
|
|
||||||
|
void updateDisplayNameFromCases();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString caseName() const override;
|
QString caseName() const override;
|
||||||
|
|
||||||
@ -75,7 +77,6 @@ private:
|
|||||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||||
|
|
||||||
void clearData( const RifEclipseSummaryAddress& address );
|
void clearData( const RifEclipseSummaryAddress& address );
|
||||||
void updateNameFromInputCases();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
caf::PdmPtrField<RimSummaryCase*> m_summaryCase1;
|
caf::PdmPtrField<RimSummaryCase*> m_summaryCase1;
|
||||||
|
Loading…
Reference in New Issue
Block a user