2017-09-06 07:09:15 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2017- Statoil ASA
|
2019-04-05 03:46:44 -05:00
|
|
|
//
|
2017-09-06 07:09:15 -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-04-05 03:46:44 -05:00
|
|
|
//
|
2017-09-06 07:09:15 -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-04-05 03:46:44 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2017-09-06 07:09:15 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicReloadSummaryCaseFeature.h"
|
|
|
|
|
|
|
|
#include "RiaLogging.h"
|
2017-10-20 03:54:48 -05:00
|
|
|
#include "RiaSummaryTools.h"
|
2020-11-10 06:44:34 -06:00
|
|
|
#include "RicReplaceSummaryCaseFeature.h"
|
2017-09-06 07:09:15 -05:00
|
|
|
|
|
|
|
#include "RimMainPlotCollection.h"
|
2019-04-05 03:46:44 -05:00
|
|
|
#include "RimObservedDataCollection.h"
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "RimObservedSummaryData.h"
|
2017-09-06 07:09:15 -05:00
|
|
|
#include "RimSummaryCase.h"
|
2017-09-07 05:01:40 -05:00
|
|
|
#include "RimSummaryCaseCollection.h"
|
2017-09-06 09:32:46 -05:00
|
|
|
#include "RimSummaryCaseMainCollection.h"
|
2022-04-06 10:39:07 -05:00
|
|
|
#include "RimSummaryMultiPlot.h"
|
|
|
|
#include "RimSummaryMultiPlotCollection.h"
|
2017-09-06 07:09:15 -05:00
|
|
|
#include "RimSummaryPlot.h"
|
|
|
|
|
|
|
|
#include "cafPdmObject.h"
|
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_CMD_SOURCE_INIT( RicReloadSummaryCaseFeature, "RicReloadSummaryCaseFeature" );
|
2017-09-06 07:09:15 -05:00
|
|
|
|
2022-08-19 07:30:25 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicReloadSummaryCaseFeature::reloadSummaryCase( RimSummaryCase* summaryCase )
|
|
|
|
{
|
|
|
|
summaryCase->createSummaryReaderInterface();
|
|
|
|
summaryCase->createRftReaderInterface();
|
|
|
|
summaryCase->refreshMetaData();
|
|
|
|
|
|
|
|
RicReplaceSummaryCaseFeature::updateRequredCalculatedCurves( summaryCase );
|
|
|
|
}
|
|
|
|
|
2017-09-06 07:09:15 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-04-05 03:46:44 -05:00
|
|
|
///
|
2017-09-06 07:09:15 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-06-26 07:28:46 -05:00
|
|
|
bool RicReloadSummaryCaseFeature::isCommandEnabled() const
|
2017-09-06 07:09:15 -05:00
|
|
|
{
|
|
|
|
std::vector<RimSummaryCase*> caseSelection = selectedSummaryCases();
|
|
|
|
|
2019-04-05 03:46:44 -05:00
|
|
|
return !caseSelection.empty();
|
2017-09-06 07:09:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-04-05 03:46:44 -05:00
|
|
|
///
|
2017-09-06 07:09:15 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicReloadSummaryCaseFeature::onActionTriggered( bool isChecked )
|
2017-09-06 07:09:15 -05:00
|
|
|
{
|
|
|
|
std::vector<RimSummaryCase*> caseSelection = selectedSummaryCases();
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( RimSummaryCase* summaryCase : caseSelection )
|
2017-09-06 07:09:15 -05:00
|
|
|
{
|
2022-08-19 07:30:25 -05:00
|
|
|
reloadSummaryCase( summaryCase );
|
2020-11-10 06:44:34 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
RiaLogging::info( QString( "Reloaded data for %1" ).arg( summaryCase->summaryHeaderFilename() ) );
|
2017-09-06 07:09:15 -05:00
|
|
|
}
|
|
|
|
|
2022-08-19 07:30:25 -05:00
|
|
|
RimMainPlotCollection::current()->loadDataAndUpdateAllPlots();
|
2017-09-06 07:09:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-04-05 03:46:44 -05:00
|
|
|
///
|
2017-09-06 07:09:15 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicReloadSummaryCaseFeature::setupActionLook( QAction* actionToSetup )
|
2017-09-06 07:09:15 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
actionToSetup->setText( "Reload" );
|
2020-10-06 10:12:58 -05:00
|
|
|
actionToSetup->setIcon( QIcon( ":/Refresh.svg" ) );
|
2017-09-06 07:09:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-04-05 03:46:44 -05:00
|
|
|
///
|
2017-09-06 07:09:15 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<RimSummaryCase*> RicReloadSummaryCaseFeature::selectedSummaryCases()
|
|
|
|
{
|
2017-09-07 05:01:40 -05:00
|
|
|
std::vector<RimSummaryCaseMainCollection*> mainCollectionSelection;
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::SelectionManager::instance()->objectsByType( &mainCollectionSelection );
|
2017-09-07 05:01:40 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( mainCollectionSelection.size() > 0 )
|
2017-09-07 05:01:40 -05:00
|
|
|
{
|
|
|
|
return mainCollectionSelection[0]->allSummaryCases();
|
|
|
|
}
|
|
|
|
|
2017-09-06 07:09:15 -05:00
|
|
|
std::vector<RimSummaryCase*> caseSelection;
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::SelectionManager::instance()->objectsByType( &caseSelection );
|
2017-09-06 07:09:15 -05:00
|
|
|
|
2019-04-05 03:46:44 -05:00
|
|
|
{
|
|
|
|
std::vector<RimSummaryCaseCollection*> collectionSelection;
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::SelectionManager::instance()->objectsByType( &collectionSelection );
|
2019-04-05 03:46:44 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( auto collection : collectionSelection )
|
2019-04-05 03:46:44 -05:00
|
|
|
{
|
|
|
|
std::vector<RimSummaryCase*> summaryCaseCollection = collection->allSummaryCases();
|
2019-09-06 03:40:57 -05:00
|
|
|
caseSelection.insert( caseSelection.end(), summaryCaseCollection.begin(), summaryCaseCollection.end() );
|
2019-04-05 03:46:44 -05:00
|
|
|
}
|
|
|
|
}
|
2017-09-06 07:09:15 -05:00
|
|
|
|
|
|
|
{
|
2019-04-05 03:46:44 -05:00
|
|
|
std::vector<RimObservedDataCollection*> collectionSelection;
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::SelectionManager::instance()->objectsByType( &collectionSelection );
|
2019-04-05 03:46:44 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( auto collection : collectionSelection )
|
2019-04-05 03:46:44 -05:00
|
|
|
{
|
2019-08-20 08:09:13 -05:00
|
|
|
std::vector<RimObservedSummaryData*> observedCases = collection->allObservedSummaryData();
|
2019-09-06 03:40:57 -05:00
|
|
|
caseSelection.insert( caseSelection.end(), observedCases.begin(), observedCases.end() );
|
2019-04-05 03:46:44 -05:00
|
|
|
}
|
2017-09-06 07:09:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return caseSelection;
|
|
|
|
}
|