2017-09-04 15:05:13 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
2017-09-05 13:26:50 +02:00
|
|
|
// Copyright (C) 2017- Statoil ASA
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
2017-09-04 15:05:13 +02: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 10:40:57 +02:00
|
|
|
//
|
2017-09-04 15:05:13 +02: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 10:40:57 +02:00
|
|
|
//
|
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2017-09-04 15:05:13 +02:00
|
|
|
// for more details.
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#include "RicCloseSummaryCaseFeature.h"
|
2017-09-05 13:26:50 +02:00
|
|
|
|
2019-05-06 10:36:05 +02:00
|
|
|
#include "RiaGuiApplication.h"
|
2017-10-20 10:54:48 +02:00
|
|
|
#include "RiaSummaryTools.h"
|
2017-09-05 13:26:50 +02:00
|
|
|
|
2017-09-04 15:05:13 +02:00
|
|
|
#include "RimMainPlotCollection.h"
|
|
|
|
|
#include "RimProject.h"
|
|
|
|
|
#include "RimSummaryCase.h"
|
2017-09-06 16:32:46 +02:00
|
|
|
#include "RimSummaryCaseMainCollection.h"
|
2017-09-05 13:26:50 +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
|
|
|
|
2018-05-22 09:36:31 +02:00
|
|
|
#include "cafAsyncObjectDeleter.h"
|
2017-09-05 13:26:50 +02:00
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
|
2017-09-04 15:05:13 +02:00
|
|
|
#include "cvfAssert.h"
|
2017-09-05 13:26:50 +02:00
|
|
|
|
2017-09-04 15:05:13 +02:00
|
|
|
#include <QAction>
|
|
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
CAF_CMD_SOURCE_INIT( RicCloseSummaryCaseFeature, "RicCloseSummaryCaseFeature" );
|
2017-09-04 15:05:13 +02:00
|
|
|
|
2017-09-05 13:26:50 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-09-05 13:26:50 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
void RicCloseSummaryCaseFeature::setupActionLook( QAction* actionToSetup )
|
2017-09-04 15:05:13 +02:00
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
actionToSetup->setText( "Close Summary Case" );
|
|
|
|
|
actionToSetup->setIcon( QIcon( ":/Erase.png" ) );
|
|
|
|
|
applyShortcutWithHintToAction( actionToSetup, QKeySequence::Delete );
|
2017-09-04 15:05:13 +02:00
|
|
|
}
|
|
|
|
|
|
2017-09-05 15:48:06 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-09-05 15:48:06 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
void RicCloseSummaryCaseFeature::deleteSummaryCases( std::vector<RimSummaryCase*>& cases )
|
2017-09-05 15:48:06 +02:00
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
RimSummaryPlotCollection* summaryPlotColl = RiaSummaryTools::summaryPlotCollection();
|
2018-05-23 13:33:10 +02:00
|
|
|
RimSummaryCaseMainCollection* summaryCaseMainCollection = RiaSummaryTools::summaryCaseMainCollection();
|
2017-09-05 15:48:06 +02:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
for ( RimSummaryCase* summaryCase : cases )
|
2017-09-05 15:48:06 +02:00
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
for ( RimSummaryPlot* summaryPlot : summaryPlotColl->summaryPlots )
|
2017-09-05 15:48:06 +02:00
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
summaryPlot->deleteCurvesAssosiatedWithCase( summaryCase );
|
2017-09-05 15:48:06 +02:00
|
|
|
}
|
|
|
|
|
summaryPlotColl->updateConnectedEditors();
|
|
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
summaryCaseMainCollection->removeCase( summaryCase );
|
2017-09-05 15:48:06 +02:00
|
|
|
}
|
2017-12-15 10:18:05 +01:00
|
|
|
|
2018-05-23 13:33:10 +02:00
|
|
|
summaryCaseMainCollection->updateAllRequiredEditors();
|
|
|
|
|
|
2019-05-06 10:36:05 +02:00
|
|
|
RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow();
|
2017-12-15 10:18:05 +01:00
|
|
|
mainPlotWindow->updateSummaryPlotToolBar();
|
2018-05-22 09:36:31 +02:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
caf::AsyncPdmObjectVectorDeleter<RimSummaryCase> summaryCaseDeleter( cases );
|
|
|
|
|
CAF_ASSERT( cases.empty() ); // vector should be empty immediately.
|
2017-09-05 15:48:06 +02:00
|
|
|
}
|
|
|
|
|
|
2017-09-04 15:05:13 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-09-04 15:05:13 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
bool RicCloseSummaryCaseFeature::isCommandEnabled()
|
|
|
|
|
{
|
2017-09-05 13:26:50 +02:00
|
|
|
std::vector<RimSummaryCase*> selection;
|
2019-09-06 10:40:57 +02:00
|
|
|
caf::SelectionManager::instance()->objectsByType( &selection );
|
2017-09-05 15:48:06 +02:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
if ( selection.size() == 0 )
|
2017-09-19 14:47:36 +02:00
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
for ( RimSummaryCase* summaryCase : selection )
|
2017-09-19 14:47:36 +02:00
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
if ( summaryCase->isObservedData() )
|
2017-09-19 14:47:36 +02:00
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
2017-09-04 15:05:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-09-04 15:05:13 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
void RicCloseSummaryCaseFeature::onActionTriggered( bool isChecked )
|
2017-09-04 15:05:13 +02:00
|
|
|
{
|
2018-03-12 11:12:39 +01:00
|
|
|
std::vector<RimSummaryCase*> selection;
|
2019-09-06 10:40:57 +02:00
|
|
|
caf::SelectionManager::instance()->objectsByType( &selection );
|
|
|
|
|
CVF_ASSERT( selection.size() > 0 );
|
|
|
|
|
|
|
|
|
|
RicCloseSummaryCaseFeature::deleteSummaryCases( selection );
|
2017-09-05 13:26:50 +02:00
|
|
|
}
|