2017-09-04 08:05:13 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2017-09-05 06:26:50 -05:00
|
|
|
// Copyright (C) 2017- Statoil ASA
|
2017-09-04 08:05:13 -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.
|
|
|
|
//
|
|
|
|
// 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 "RicCloseSummaryCaseFeature.h"
|
2017-09-05 06:26:50 -05:00
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
2017-10-20 03:54:48 -05:00
|
|
|
#include "RiaSummaryTools.h"
|
2017-09-05 06:26:50 -05:00
|
|
|
|
2017-09-04 08:05:13 -05:00
|
|
|
#include "RimMainPlotCollection.h"
|
|
|
|
#include "RimProject.h"
|
|
|
|
#include "RimSummaryCase.h"
|
2017-09-06 09:32:46 -05:00
|
|
|
#include "RimSummaryCaseMainCollection.h"
|
2017-09-05 06:26:50 -05:00
|
|
|
#include "RimSummaryPlot.h"
|
|
|
|
#include "RimSummaryPlotCollection.h"
|
|
|
|
|
2018-04-26 23:28:08 -05:00
|
|
|
#include "RiuPlotMainWindow.h"
|
2017-12-15 03:18:05 -06:00
|
|
|
|
2018-05-22 02:36:31 -05:00
|
|
|
#include "cafAsyncObjectDeleter.h"
|
2017-09-05 06:26:50 -05:00
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
2017-09-04 08:05:13 -05:00
|
|
|
#include "cvfAssert.h"
|
2017-09-05 06:26:50 -05:00
|
|
|
|
2017-09-04 08:05:13 -05:00
|
|
|
#include <QAction>
|
|
|
|
|
|
|
|
CAF_CMD_SOURCE_INIT(RicCloseSummaryCaseFeature, "RicCloseSummaryCaseFeature");
|
|
|
|
|
2017-09-05 06:26:50 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-09-04 08:05:13 -05:00
|
|
|
void RicCloseSummaryCaseFeature::setupActionLook(QAction* actionToSetup)
|
|
|
|
{
|
2018-03-12 05:12:39 -05:00
|
|
|
actionToSetup->setText("Close Summary Case");
|
|
|
|
actionToSetup->setIcon(QIcon(":/Erase.png"));
|
2017-09-04 08:05:13 -05:00
|
|
|
}
|
|
|
|
|
2017-09-05 08:48:06 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-05-22 02:36:31 -05:00
|
|
|
void RicCloseSummaryCaseFeature::deleteSummaryCases(std::vector<RimSummaryCase*>& cases)
|
2017-09-05 08:48:06 -05:00
|
|
|
{
|
2017-10-20 03:54:48 -05:00
|
|
|
RimSummaryPlotCollection* summaryPlotColl = RiaSummaryTools::summaryPlotCollection();
|
2018-05-23 06:33:10 -05:00
|
|
|
RimSummaryCaseMainCollection* summaryCaseMainCollection = RiaSummaryTools::summaryCaseMainCollection();
|
2017-09-05 08:48:06 -05:00
|
|
|
|
|
|
|
for (RimSummaryCase* summaryCase : cases)
|
|
|
|
{
|
|
|
|
for (RimSummaryPlot* summaryPlot : summaryPlotColl->summaryPlots)
|
|
|
|
{
|
2017-09-14 06:56:50 -05:00
|
|
|
summaryPlot->deleteCurvesAssosiatedWithCase(summaryCase);
|
2017-09-05 08:48:06 -05:00
|
|
|
}
|
|
|
|
summaryPlotColl->updateConnectedEditors();
|
|
|
|
|
2017-09-08 08:26:13 -05:00
|
|
|
summaryCaseMainCollection->removeCase(summaryCase);
|
2017-09-05 08:48:06 -05:00
|
|
|
}
|
2017-12-15 03:18:05 -06:00
|
|
|
|
2018-05-23 06:33:10 -05:00
|
|
|
summaryCaseMainCollection->updateAllRequiredEditors();
|
|
|
|
|
2018-04-26 23:28:08 -05:00
|
|
|
RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow();
|
2017-12-15 03:18:05 -06:00
|
|
|
mainPlotWindow->updateSummaryPlotToolBar();
|
2018-05-22 02:36:31 -05:00
|
|
|
|
2018-06-08 05:57:58 -05:00
|
|
|
caf::AsyncPdmObjectVectorDeleter<RimSummaryCase> summaryCaseDeleter(cases);
|
|
|
|
CAF_ASSERT(cases.empty()); // vector should be empty immediately.
|
2017-09-05 08:48:06 -05:00
|
|
|
}
|
|
|
|
|
2017-09-04 08:05:13 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RicCloseSummaryCaseFeature::isCommandEnabled()
|
|
|
|
{
|
2017-09-05 06:26:50 -05:00
|
|
|
std::vector<RimSummaryCase*> selection;
|
|
|
|
caf::SelectionManager::instance()->objectsByType(&selection);
|
2017-09-05 08:48:06 -05:00
|
|
|
|
2017-09-19 07:47:36 -05:00
|
|
|
if (selection.size() == 0)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (RimSummaryCase* summaryCase : selection)
|
|
|
|
{
|
|
|
|
if (summaryCase->isObservedData())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
2017-09-04 08:05:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-09-05 06:26:50 -05:00
|
|
|
void RicCloseSummaryCaseFeature::onActionTriggered(bool isChecked)
|
2017-09-04 08:05:13 -05:00
|
|
|
{
|
2018-03-12 05:12:39 -05:00
|
|
|
std::vector<RimSummaryCase*> selection;
|
|
|
|
caf::SelectionManager::instance()->objectsByType(&selection);
|
2017-09-05 06:26:50 -05:00
|
|
|
CVF_ASSERT(selection.size() > 0);
|
2017-09-05 08:48:06 -05:00
|
|
|
|
|
|
|
RicCloseSummaryCaseFeature::deleteSummaryCases(selection);
|
2017-09-05 06:26:50 -05:00
|
|
|
}
|