mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-05 21:53:27 -06:00
120 lines
4.1 KiB
C++
120 lines
4.1 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// 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.
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "RicReloadSummaryCaseFeature.h"
|
|
|
|
#include "RiaApplication.h"
|
|
#include "RiaLogging.h"
|
|
#include "RiaSummaryTools.h"
|
|
|
|
#include "RimMainPlotCollection.h"
|
|
#include "RimProject.h"
|
|
#include "RimSummaryCase.h"
|
|
#include "RimSummaryCaseCollection.h"
|
|
#include "RimSummaryCaseMainCollection.h"
|
|
#include "RimSummaryPlot.h"
|
|
#include "RimSummaryPlotCollection.h"
|
|
|
|
#include "cafPdmObject.h"
|
|
#include "cafSelectionManager.h"
|
|
|
|
#include <QAction>
|
|
|
|
CAF_CMD_SOURCE_INIT(RicReloadSummaryCaseFeature, "RicReloadSummaryCaseFeature");
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RicReloadSummaryCaseFeature::isCommandEnabled()
|
|
{
|
|
std::vector<RimSummaryCase*> caseSelection = selectedSummaryCases();
|
|
|
|
if (caseSelection.size() == 0)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
for (RimSummaryCase* summaryCase : caseSelection)
|
|
{
|
|
if (summaryCase->isObservedData())
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicReloadSummaryCaseFeature::onActionTriggered(bool isChecked)
|
|
{
|
|
RimSummaryPlotCollection* summaryPlotColl = RiaSummaryTools::summaryPlotCollection();
|
|
|
|
std::vector<RimSummaryCase*> caseSelection = selectedSummaryCases();
|
|
for (RimSummaryCase* summaryCase : caseSelection)
|
|
{
|
|
summaryCase->createSummaryReaderInterface();
|
|
|
|
RiaLogging::info(QString("Reloaded data for %1").arg(summaryCase->summaryHeaderFilename()));
|
|
}
|
|
|
|
for (RimSummaryPlot* summaryPlot : summaryPlotColl->summaryPlots)
|
|
{
|
|
summaryPlot->loadDataAndUpdate();
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicReloadSummaryCaseFeature::setupActionLook(QAction* actionToSetup)
|
|
{
|
|
actionToSetup->setText("Reload");
|
|
actionToSetup->setIcon(QIcon(":/Refresh-32.png"));
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
std::vector<RimSummaryCase*> RicReloadSummaryCaseFeature::selectedSummaryCases()
|
|
{
|
|
std::vector<RimSummaryCaseMainCollection*> mainCollectionSelection;
|
|
caf::SelectionManager::instance()->objectsByType(&mainCollectionSelection);
|
|
|
|
if (mainCollectionSelection.size() > 0)
|
|
{
|
|
return mainCollectionSelection[0]->allSummaryCases();
|
|
}
|
|
|
|
std::vector<RimSummaryCase*> caseSelection;
|
|
caf::SelectionManager::instance()->objectsByType(&caseSelection);
|
|
|
|
std::vector<RimSummaryCaseCollection*> collectionSelection;
|
|
caf::SelectionManager::instance()->objectsByType(&collectionSelection);
|
|
|
|
for (auto collection : collectionSelection)
|
|
{
|
|
std::vector<RimSummaryCase*> summaryCaseCollection = collection->allSummaryCases();
|
|
caseSelection.insert(caseSelection.end(), summaryCaseCollection.begin(), summaryCaseCollection.end());
|
|
}
|
|
|
|
return caseSelection;
|
|
}
|