2017-09-05 08:48:06 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2017- Statoil ASA
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2017-09-05 08:48:06 -05:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2017-09-05 08:48:06 -05:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2017-09-05 08:48:06 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2017-09-08 08:26:13 -05:00
|
|
|
#include "RicCloseSummaryCaseInCollectionFeature.h"
|
2017-09-05 08:48:06 -05:00
|
|
|
|
2019-05-06 03:36:05 -05:00
|
|
|
#include "RiaGuiApplication.h"
|
2017-09-05 08:48:06 -05:00
|
|
|
|
|
|
|
#include "RicCloseSummaryCaseFeature.h"
|
|
|
|
|
2018-06-28 03:15:42 -05:00
|
|
|
#include "RimDerivedEnsembleCaseCollection.h"
|
2017-09-05 08:48:06 -05:00
|
|
|
#include "RimMainPlotCollection.h"
|
|
|
|
#include "RimProject.h"
|
|
|
|
#include "RimSummaryCase.h"
|
2017-09-07 06:00:53 -05:00
|
|
|
#include "RimSummaryCaseCollection.h"
|
2017-09-06 09:32:46 -05:00
|
|
|
#include "RimSummaryCaseMainCollection.h"
|
2017-09-05 08:48:06 -05:00
|
|
|
#include "RimSummaryPlot.h"
|
|
|
|
|
2018-04-26 23:28:08 -05:00
|
|
|
#include "RiuPlotMainWindow.h"
|
2017-12-15 03:18:05 -06:00
|
|
|
|
2017-09-05 08:48:06 -05:00
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
|
|
|
#include "cvfAssert.h"
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
#include <vector>
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_CMD_SOURCE_INIT( RicCloseSummaryCaseInCollectionFeature, "RicCloseSummaryCaseInCollectionFeature" );
|
2017-09-05 08:48:06 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-09-05 08:48:06 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicCloseSummaryCaseInCollectionFeature::setupActionLook( QAction* actionToSetup )
|
2017-09-05 08:48:06 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
actionToSetup->setText( "Close Summary Cases" );
|
2020-10-06 10:12:58 -05:00
|
|
|
actionToSetup->setIcon( QIcon( ":/Close.svg" ) );
|
2017-09-05 08:48:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-09-05 08:48:06 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-09-08 08:26:13 -05:00
|
|
|
bool RicCloseSummaryCaseInCollectionFeature::isCommandEnabled()
|
2017-09-05 08:48:06 -05:00
|
|
|
{
|
2017-09-06 09:32:46 -05:00
|
|
|
std::vector<RimSummaryCaseMainCollection*> summaryCaseMainCollections;
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::SelectionManager::instance()->objectsByType( &summaryCaseMainCollections );
|
2017-09-07 06:00:53 -05:00
|
|
|
|
|
|
|
std::vector<RimSummaryCaseCollection*> summaryCaseCollections;
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::SelectionManager::instance()->objectsByType( &summaryCaseCollections );
|
2017-09-07 06:00:53 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
summaryCaseCollections.erase( std::remove_if( summaryCaseCollections.begin(),
|
|
|
|
summaryCaseCollections.end(),
|
2023-04-13 00:05:53 -05:00
|
|
|
[]( RimSummaryCaseCollection* coll )
|
|
|
|
{ return dynamic_cast<RimDerivedEnsembleCaseCollection*>( coll ) != nullptr; } ),
|
2019-09-06 03:40:57 -05:00
|
|
|
summaryCaseCollections.end() );
|
2018-06-28 03:15:42 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
return ( summaryCaseMainCollections.size() > 0 || summaryCaseCollections.size() > 0 );
|
2017-09-05 08:48:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-09-05 08:48:06 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicCloseSummaryCaseInCollectionFeature::onActionTriggered( bool isChecked )
|
2017-09-05 08:48:06 -05:00
|
|
|
{
|
2017-09-06 09:32:46 -05:00
|
|
|
std::vector<RimSummaryCaseMainCollection*> summaryCaseMainCollections;
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::SelectionManager::instance()->objectsByType( &summaryCaseMainCollections );
|
2017-09-05 08:48:06 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( summaryCaseMainCollections.size() > 0 )
|
2017-09-07 06:00:53 -05:00
|
|
|
{
|
2018-05-22 02:36:31 -05:00
|
|
|
std::vector<RimSummaryCase*> allSummaryCases = summaryCaseMainCollections[0]->allSummaryCases();
|
2019-09-06 03:40:57 -05:00
|
|
|
RicCloseSummaryCaseFeature::deleteSummaryCases( allSummaryCases );
|
2017-09-07 06:00:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<RimSummaryCaseCollection*> summaryCaseCollections;
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::SelectionManager::instance()->objectsByType( &summaryCaseCollections );
|
2017-09-07 06:00:53 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( RimSummaryCaseCollection* summaryCaseCollection : summaryCaseCollections )
|
2017-09-07 06:00:53 -05:00
|
|
|
{
|
2018-05-22 02:36:31 -05:00
|
|
|
std::vector<RimSummaryCase*> collectionSummaryCases = summaryCaseCollection->allSummaryCases();
|
2019-09-06 03:40:57 -05:00
|
|
|
RicCloseSummaryCaseFeature::deleteSummaryCases( collectionSummaryCases );
|
2017-09-07 06:00:53 -05:00
|
|
|
}
|
2017-12-15 03:18:05 -06:00
|
|
|
|
2019-05-06 03:36:05 -05:00
|
|
|
RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow();
|
2022-04-07 09:24:27 -05:00
|
|
|
mainPlotWindow->updateMultiPlotToolBar();
|
2017-09-05 08:48:06 -05:00
|
|
|
}
|