2017-09-05 15:48:06 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2017- Statoil 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.
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2017-09-08 15:26:13 +02:00
|
|
|
#include "RicCloseSummaryCaseInCollectionFeature.h"
|
2017-09-05 15:48:06 +02:00
|
|
|
|
2019-05-06 10:36:05 +02:00
|
|
|
#include "RiaGuiApplication.h"
|
2017-09-05 15:48:06 +02:00
|
|
|
|
|
|
|
|
#include "RicCloseSummaryCaseFeature.h"
|
|
|
|
|
|
2018-06-28 10:15:42 +02:00
|
|
|
#include "RimDerivedEnsembleCaseCollection.h"
|
2017-09-05 15:48:06 +02:00
|
|
|
#include "RimMainPlotCollection.h"
|
|
|
|
|
#include "RimProject.h"
|
|
|
|
|
#include "RimSummaryCase.h"
|
2017-09-07 13:00:53 +02:00
|
|
|
#include "RimSummaryCaseCollection.h"
|
2017-09-06 16:32:46 +02:00
|
|
|
#include "RimSummaryCaseMainCollection.h"
|
2017-09-05 15:48:06 +02:00
|
|
|
#include "RimSummaryPlot.h"
|
|
|
|
|
#include "RimSummaryPlotCollection.h"
|
|
|
|
|
|
2018-04-27 06:28:08 +02:00
|
|
|
#include "RiuPlotMainWindow.h"
|
2017-12-15 10:18:05 +01:00
|
|
|
|
2017-09-05 15:48:06 +02:00
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
|
|
|
|
|
#include "cvfAssert.h"
|
|
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
|
2017-09-08 15:26:13 +02:00
|
|
|
CAF_CMD_SOURCE_INIT(RicCloseSummaryCaseInCollectionFeature, "RicCloseSummaryCaseInCollectionFeature");
|
2017-09-05 15:48:06 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-09-08 15:26:13 +02:00
|
|
|
void RicCloseSummaryCaseInCollectionFeature::setupActionLook(QAction* actionToSetup)
|
2017-09-05 15:48:06 +02:00
|
|
|
{
|
2017-09-08 15:26:13 +02:00
|
|
|
actionToSetup->setText("Close Summary Cases");
|
2017-09-05 15:48:06 +02:00
|
|
|
actionToSetup->setIcon(QIcon(":/Erase.png"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-09-08 15:26:13 +02:00
|
|
|
bool RicCloseSummaryCaseInCollectionFeature::isCommandEnabled()
|
2017-09-05 15:48:06 +02:00
|
|
|
{
|
2017-09-06 16:32:46 +02:00
|
|
|
std::vector<RimSummaryCaseMainCollection*> summaryCaseMainCollections;
|
|
|
|
|
caf::SelectionManager::instance()->objectsByType(&summaryCaseMainCollections);
|
2017-09-07 13:00:53 +02:00
|
|
|
|
|
|
|
|
std::vector<RimSummaryCaseCollection*> summaryCaseCollections;
|
|
|
|
|
caf::SelectionManager::instance()->objectsByType(&summaryCaseCollections);
|
|
|
|
|
|
2018-06-28 10:15:42 +02:00
|
|
|
summaryCaseCollections.erase(std::remove_if(summaryCaseCollections.begin(), summaryCaseCollections.end(), [](RimSummaryCaseCollection* coll)
|
|
|
|
|
{
|
|
|
|
|
return dynamic_cast<RimDerivedEnsembleCaseCollection*>(coll) != nullptr;
|
|
|
|
|
}), summaryCaseCollections.end());
|
|
|
|
|
|
2017-09-07 13:00:53 +02:00
|
|
|
return (summaryCaseMainCollections.size() > 0 || summaryCaseCollections.size() > 0);
|
2017-09-05 15:48:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-09-08 15:26:13 +02:00
|
|
|
void RicCloseSummaryCaseInCollectionFeature::onActionTriggered(bool isChecked)
|
2017-09-05 15:48:06 +02:00
|
|
|
{
|
2017-09-06 16:32:46 +02:00
|
|
|
std::vector<RimSummaryCaseMainCollection*> summaryCaseMainCollections;
|
|
|
|
|
caf::SelectionManager::instance()->objectsByType(&summaryCaseMainCollections);
|
2017-09-05 15:48:06 +02:00
|
|
|
|
2017-09-07 13:00:53 +02:00
|
|
|
if (summaryCaseMainCollections.size() > 0)
|
|
|
|
|
{
|
2018-05-22 09:36:31 +02:00
|
|
|
std::vector<RimSummaryCase*> allSummaryCases = summaryCaseMainCollections[0]->allSummaryCases();
|
|
|
|
|
RicCloseSummaryCaseFeature::deleteSummaryCases(allSummaryCases);
|
2017-09-07 13:00:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::vector<RimSummaryCaseCollection*> summaryCaseCollections;
|
|
|
|
|
caf::SelectionManager::instance()->objectsByType(&summaryCaseCollections);
|
|
|
|
|
|
|
|
|
|
for (RimSummaryCaseCollection* summaryCaseCollection : summaryCaseCollections)
|
|
|
|
|
{
|
2018-05-22 09:36:31 +02:00
|
|
|
std::vector<RimSummaryCase*> collectionSummaryCases = summaryCaseCollection->allSummaryCases();
|
|
|
|
|
RicCloseSummaryCaseFeature::deleteSummaryCases(collectionSummaryCases);
|
2017-09-07 13:00:53 +02:00
|
|
|
}
|
2017-12-15 10:18:05 +01:00
|
|
|
|
2019-05-06 10:36:05 +02:00
|
|
|
RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow();
|
2017-12-15 10:18:05 +01:00
|
|
|
mainPlotWindow->updateSummaryPlotToolBar();
|
2017-09-05 15:48:06 +02:00
|
|
|
}
|
|
|
|
|
|