2017-09-27 08:07:27 -05: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.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicCloseObservedDataFeature.h"
|
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
2017-10-20 03:54:48 -05:00
|
|
|
#include "RiaSummaryTools.h"
|
2017-09-27 08:07:27 -05:00
|
|
|
|
2019-08-20 08:09:13 -05:00
|
|
|
#include "RimMainPlotCollection.h"
|
|
|
|
#include "RimObservedFmuRftData.h"
|
|
|
|
#include "RimObservedSummaryData.h"
|
2017-09-27 08:07:27 -05:00
|
|
|
#include "RimObservedDataCollection.h"
|
|
|
|
#include "RimProject.h"
|
2019-08-20 08:09:13 -05:00
|
|
|
#include "RimRftPlotCollection.h"
|
2017-09-27 08:07:27 -05:00
|
|
|
#include "RimSummaryPlot.h"
|
|
|
|
#include "RimSummaryPlotCollection.h"
|
2019-08-20 08:09:13 -05:00
|
|
|
#include "RimWellRftPlot.h"
|
2017-09-27 08:07:27 -05:00
|
|
|
|
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
|
|
|
#include "cvfAssert.h"
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
|
|
|
CAF_CMD_SOURCE_INIT(RicCloseObservedDataFeature, "RicCloseObservedDataFeature");
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicCloseObservedDataFeature::setupActionLook(QAction* actionToSetup)
|
|
|
|
{
|
2018-03-12 05:12:39 -05:00
|
|
|
actionToSetup->setText("Close");
|
|
|
|
actionToSetup->setIcon(QIcon(":/Erase.png"));
|
2017-09-27 08:07:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-08-20 08:09:13 -05:00
|
|
|
void RicCloseObservedDataFeature::deleteObservedSummaryData(const std::vector<RimObservedSummaryData*>& data)
|
2017-09-27 08:07:27 -05:00
|
|
|
{
|
2017-10-20 03:54:48 -05:00
|
|
|
RimSummaryPlotCollection* summaryPlotColl = RiaSummaryTools::summaryPlotCollection();
|
2017-09-27 08:07:27 -05:00
|
|
|
|
2019-08-20 08:09:13 -05:00
|
|
|
for (RimObservedSummaryData* observedData : data)
|
2017-09-27 08:07:27 -05:00
|
|
|
{
|
|
|
|
for (RimSummaryPlot* summaryPlot : summaryPlotColl->summaryPlots)
|
|
|
|
{
|
|
|
|
summaryPlot->deleteCurvesAssosiatedWithCase(observedData);
|
|
|
|
}
|
|
|
|
summaryPlotColl->updateConnectedEditors();
|
|
|
|
|
|
|
|
RimObservedDataCollection* observedDataCollection = nullptr;
|
|
|
|
observedData->firstAncestorOrThisOfTypeAsserted(observedDataCollection);
|
|
|
|
|
2019-08-20 08:09:13 -05:00
|
|
|
observedDataCollection->removeObservedSummaryData(observedData);
|
|
|
|
delete observedData;
|
|
|
|
observedDataCollection->updateConnectedEditors();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicCloseObservedDataFeature::deleteObservedRmuRftData(const std::vector<RimObservedFmuRftData*>& data)
|
|
|
|
{
|
|
|
|
RimProject* proj = RiaApplication::instance()->project();
|
|
|
|
RimRftPlotCollection* rftPlotColl = proj->mainPlotCollection()->rftPlotCollection();
|
|
|
|
|
|
|
|
for (RimObservedFmuRftData* observedData : data)
|
|
|
|
{
|
|
|
|
RimObservedDataCollection* observedDataCollection = nullptr;
|
|
|
|
observedData->firstAncestorOrThisOfTypeAsserted(observedDataCollection);
|
|
|
|
|
|
|
|
for (RimWellRftPlot* plot : rftPlotColl->rftPlots())
|
|
|
|
{
|
|
|
|
plot->deleteCurvesAssosicatedWithObservedData(observedData);
|
|
|
|
}
|
|
|
|
observedDataCollection->removeObservedFmuRftData(observedData);
|
2017-09-27 08:07:27 -05:00
|
|
|
delete observedData;
|
|
|
|
observedDataCollection->updateConnectedEditors();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RicCloseObservedDataFeature::isCommandEnabled()
|
|
|
|
{
|
2019-08-20 08:09:13 -05:00
|
|
|
std::vector<RimObservedSummaryData*> summarySelection;
|
|
|
|
caf::SelectionManager::instance()->objectsByType(&summarySelection);
|
|
|
|
|
|
|
|
std::vector<RimObservedFmuRftData*> fmuRftSelection;
|
|
|
|
caf::SelectionManager::instance()->objectsByType(&fmuRftSelection);
|
2017-09-27 08:07:27 -05:00
|
|
|
|
2019-08-20 08:09:13 -05:00
|
|
|
if (summarySelection.size() == 0 && fmuRftSelection.size() == 0)
|
2017-09-27 08:07:27 -05:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2019-08-20 08:09:13 -05:00
|
|
|
for (RimObservedSummaryData* data : summarySelection)
|
2017-09-27 08:07:27 -05:00
|
|
|
{
|
|
|
|
if (!data->isObservedData())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicCloseObservedDataFeature::onActionTriggered(bool isChecked)
|
|
|
|
{
|
2019-08-20 08:09:13 -05:00
|
|
|
std::vector<RimObservedSummaryData*> summarySelection;
|
|
|
|
caf::SelectionManager::instance()->objectsByType(&summarySelection);
|
|
|
|
|
|
|
|
std::vector<RimObservedFmuRftData*> fmuRftSelection;
|
|
|
|
caf::SelectionManager::instance()->objectsByType(&fmuRftSelection);
|
|
|
|
|
|
|
|
CVF_ASSERT(!(summarySelection.empty() && fmuRftSelection.empty()));
|
2017-09-27 08:07:27 -05:00
|
|
|
|
2019-08-20 08:09:13 -05:00
|
|
|
RicCloseObservedDataFeature::deleteObservedSummaryData(summarySelection);
|
|
|
|
RicCloseObservedDataFeature::deleteObservedRmuRftData(fmuRftSelection);
|
2017-09-27 08:07:27 -05:00
|
|
|
}
|