2015-08-14 09:45:57 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2015- Statoil ASA
|
|
|
|
|
// Copyright (C) 2015- Ceetron Solutions AS
|
|
|
|
|
//
|
|
|
|
|
// 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.
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
2015-08-11 20:59:05 +02:00
|
|
|
|
|
|
|
|
#include "RicDeleteItemFeature.h"
|
|
|
|
|
#include "RicDeleteItemExec.h"
|
|
|
|
|
#include "RicDeleteItemExecData.h"
|
|
|
|
|
|
2017-01-02 11:59:30 +01:00
|
|
|
#include "RimCellRangeFilter.h"
|
2018-06-28 10:15:42 +02:00
|
|
|
#include "RimDerivedEnsembleCaseCollection.h"
|
2017-01-02 11:59:30 +01:00
|
|
|
#include "RimEclipseInputProperty.h"
|
|
|
|
|
#include "RimEclipsePropertyFilter.h"
|
|
|
|
|
#include "RimEclipseView.h"
|
2018-05-31 10:23:51 +02:00
|
|
|
#include "RimEnsembleCurveFilter.h"
|
2018-04-19 14:00:00 +02:00
|
|
|
#include "RimEnsembleCurveSet.h"
|
2017-05-05 11:21:40 +02:00
|
|
|
#include "RimFishbonesMultipleSubs.h"
|
2017-01-02 11:59:30 +01:00
|
|
|
#include "RimFormationNames.h"
|
|
|
|
|
#include "RimFormationNamesCollection.h"
|
|
|
|
|
#include "RimGeoMechPropertyFilter.h"
|
|
|
|
|
#include "RimGeoMechView.h"
|
2017-03-19 08:53:15 +01:00
|
|
|
#include "RimGridTimeHistoryCurve.h"
|
2017-01-02 11:59:30 +01:00
|
|
|
#include "RimIdenticalGridCaseGroup.h"
|
|
|
|
|
#include "RimIntersection.h"
|
|
|
|
|
#include "RimIntersectionBox.h"
|
|
|
|
|
#include "RimSummaryCurve.h"
|
|
|
|
|
#include "RimSummaryCurveFilter.h"
|
|
|
|
|
#include "RimSummaryPlot.h"
|
|
|
|
|
#include "RimViewController.h"
|
2017-02-09 08:34:28 +01:00
|
|
|
#include "RimWellAllocationPlot.h"
|
2017-02-08 07:35:48 +01:00
|
|
|
#include "RimWellFlowRateCurve.h"
|
2017-01-02 11:59:30 +01:00
|
|
|
#include "RimWellLogCurve.h"
|
2015-09-08 09:49:07 +02:00
|
|
|
#include "RimWellLogPlot.h"
|
2015-11-04 16:14:42 +01:00
|
|
|
#include "RimWellLogTrack.h"
|
2017-05-19 13:47:44 +02:00
|
|
|
#include "RimFishboneWellPath.h"
|
2017-05-11 13:34:00 +02:00
|
|
|
#include "RimPerforationInterval.h"
|
2017-08-17 12:52:18 +02:00
|
|
|
#include "RimFlowCharacteristicsPlot.h"
|
2017-08-17 14:33:52 +02:00
|
|
|
#include "RimAsciiDataCurve.h"
|
2017-10-10 11:18:35 +02:00
|
|
|
#include "RimWellLogRftCurve.h"
|
|
|
|
|
#include "RimWellRftPlot.h"
|
2018-10-19 14:44:17 +02:00
|
|
|
#include "RimWellPathValve.h"
|
2018-11-27 15:43:44 +01:00
|
|
|
#include "RimTextAnnotation.h"
|
2018-12-14 15:32:32 +01:00
|
|
|
#include "RimReachCircleAnnotation.h"
|
|
|
|
|
#include "RimPolylinesAnnotation.h"
|
2017-08-22 11:38:31 +02:00
|
|
|
#include "RimEllipseFractureTemplate.h"
|
|
|
|
|
#include "RimSimWellFracture.h"
|
|
|
|
|
#include "RimSimWellFractureCollection.h"
|
|
|
|
|
#include "RimStimPlanFractureTemplate.h"
|
2018-12-13 19:49:37 +01:00
|
|
|
#include "RimValveTemplate.h"
|
2017-01-02 11:59:30 +01:00
|
|
|
#include "RimWellPathFracture.h"
|
|
|
|
|
#include "RimWellPathFractureCollection.h"
|
2017-08-22 11:38:31 +02:00
|
|
|
|
2015-09-08 09:49:07 +02:00
|
|
|
|
2018-12-13 19:49:37 +01:00
|
|
|
|
2015-08-11 20:59:05 +02:00
|
|
|
#include "cafCmdExecCommandManager.h"
|
|
|
|
|
#include "cafCmdSelectionHelper.h"
|
|
|
|
|
#include "cafPdmChildArrayField.h"
|
|
|
|
|
#include "cafPdmField.h"
|
|
|
|
|
#include "cafPdmReferenceHelper.h"
|
|
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
|
2017-05-19 13:40:38 +02:00
|
|
|
CAF_CMD_SOURCE_INIT(RicDeleteItemFeature, "RicDeleteItemFeature");
|
2015-08-11 20:59:05 +02:00
|
|
|
|
2017-05-19 13:40:38 +02:00
|
|
|
bool isDeletable(caf::PdmUiItem* uiItem)
|
2016-11-17 14:47:43 +01:00
|
|
|
{
|
2017-02-21 12:51:55 +01:00
|
|
|
// Enable delete of well allocation plots
|
|
|
|
|
if (dynamic_cast<RimWellAllocationPlot*>(uiItem)) return true;
|
2017-08-17 12:52:18 +02:00
|
|
|
if (dynamic_cast<RimFlowCharacteristicsPlot*>(uiItem)) return true;
|
2017-02-21 12:51:55 +01:00
|
|
|
|
|
|
|
|
// Disable delete of all sub objects of a well allocation plot
|
2017-02-09 08:34:28 +01:00
|
|
|
caf::PdmObjectHandle* destinationObject = dynamic_cast<caf::PdmObjectHandle*>(uiItem);
|
|
|
|
|
if (destinationObject)
|
|
|
|
|
{
|
|
|
|
|
RimWellAllocationPlot* wellAllocationPlot = nullptr;
|
2017-10-10 11:18:35 +02:00
|
|
|
RimWellRftPlot* rftPlot = nullptr;
|
2017-02-09 08:34:28 +01:00
|
|
|
destinationObject->firstAncestorOrThisOfType(wellAllocationPlot);
|
2017-10-10 11:18:35 +02:00
|
|
|
destinationObject->firstAncestorOrThisOfType(rftPlot);
|
2017-02-09 08:34:28 +01:00
|
|
|
|
2017-10-10 11:18:35 +02:00
|
|
|
if (wellAllocationPlot || rftPlot)
|
2017-02-09 08:34:28 +01:00
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-02-07 09:28:43 +01:00
|
|
|
|
2016-11-17 14:47:43 +01:00
|
|
|
if (dynamic_cast<RimGeoMechView*>(uiItem)) return true;
|
|
|
|
|
if (dynamic_cast<RimEclipseView*>(uiItem)) return true;
|
|
|
|
|
if (dynamic_cast<RimIdenticalGridCaseGroup*>(uiItem)) return true;
|
|
|
|
|
if (dynamic_cast<RimEclipseInputProperty*>(uiItem)) return true;
|
|
|
|
|
if (dynamic_cast<RimCellRangeFilter*>(uiItem)) return true;
|
|
|
|
|
if (dynamic_cast<RimEclipsePropertyFilter*>(uiItem)) return true;
|
|
|
|
|
if (dynamic_cast<RimGeoMechPropertyFilter*>(uiItem)) return true;
|
|
|
|
|
if (dynamic_cast<RimViewController*>(uiItem)) return true;
|
|
|
|
|
if (dynamic_cast<RimWellLogPlot*>(uiItem)) return true;
|
|
|
|
|
if (dynamic_cast<RimWellLogCurve*>(uiItem)) return true;
|
|
|
|
|
if (dynamic_cast<RimSummaryPlot*>(uiItem)) return true;
|
|
|
|
|
if (dynamic_cast<RimSummaryCurve*>(uiItem)) return true;
|
2017-05-11 11:12:49 +02:00
|
|
|
if (dynamic_cast<RimGridTimeHistoryCurve*>(uiItem)) return true;
|
2016-11-17 14:47:43 +01:00
|
|
|
if (dynamic_cast<RimIntersection*>(uiItem)) return true;
|
|
|
|
|
if (dynamic_cast<RimIntersectionBox*>(uiItem)) return true;
|
|
|
|
|
if (dynamic_cast<RimFormationNames*>(uiItem)) return true;
|
|
|
|
|
if (dynamic_cast<RimFormationNamesCollection*>(uiItem)) return true;
|
2017-08-17 14:33:52 +02:00
|
|
|
if (dynamic_cast<RimFishboneWellPath*>(uiItem)) return true;
|
2017-05-11 11:12:49 +02:00
|
|
|
if (dynamic_cast<RimFishbonesMultipleSubs*>(uiItem)) return true;
|
2017-05-11 13:34:00 +02:00
|
|
|
if (dynamic_cast<RimPerforationInterval*>(uiItem)) return true;
|
2017-08-17 14:33:52 +02:00
|
|
|
if (dynamic_cast<RimAsciiDataCurve*>(uiItem)) return true;
|
2017-08-22 11:38:31 +02:00
|
|
|
if (dynamic_cast<RimWellPathFractureCollection*>(uiItem)) return true;
|
|
|
|
|
if (dynamic_cast<RimWellPathFracture*>(uiItem)) return true;
|
|
|
|
|
if (dynamic_cast<RimEllipseFractureTemplate*>(uiItem)) return true;
|
|
|
|
|
if (dynamic_cast<RimStimPlanFractureTemplate*>(uiItem)) return true;
|
2018-12-13 19:49:37 +01:00
|
|
|
if (dynamic_cast<RimValveTemplate*>(uiItem)) return true;
|
2017-08-22 11:38:31 +02:00
|
|
|
if (dynamic_cast<RimSimWellFractureCollection*>(uiItem)) return true;
|
|
|
|
|
if (dynamic_cast<RimSimWellFracture*>(uiItem)) return true;
|
2018-04-19 14:00:00 +02:00
|
|
|
if (dynamic_cast<RimEnsembleCurveSet*>(uiItem)) return true;
|
2018-05-31 10:23:51 +02:00
|
|
|
if (dynamic_cast<RimEnsembleCurveFilter*>(uiItem)) return true;
|
2018-06-28 10:15:42 +02:00
|
|
|
if (dynamic_cast<RimDerivedEnsembleCaseCollection*>(uiItem)) return true;
|
2018-10-19 14:44:17 +02:00
|
|
|
if (dynamic_cast<RimWellPathValve*>(uiItem)) return true;
|
2018-11-27 15:43:44 +01:00
|
|
|
if (dynamic_cast<RimTextAnnotation*>(uiItem)) return true;
|
2018-12-14 15:32:32 +01:00
|
|
|
if (dynamic_cast<RimReachCircleAnnotation*>(uiItem)) return true;
|
|
|
|
|
if (dynamic_cast<RimPolylinesAnnotation*>(uiItem)) return true;
|
2016-11-17 14:47:43 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
2015-08-11 20:59:05 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
bool RicDeleteItemFeature::isCommandEnabled()
|
|
|
|
|
{
|
2017-05-19 13:40:38 +02:00
|
|
|
std::vector<caf::PdmUiItem*> items;
|
2016-11-17 14:47:43 +01:00
|
|
|
caf::SelectionManager::instance()->selectedItems(items);
|
|
|
|
|
|
|
|
|
|
if (items.empty() ) return false;
|
2015-08-11 20:59:05 +02:00
|
|
|
|
2017-05-19 13:40:38 +02:00
|
|
|
for (caf::PdmUiItem* item : items)
|
2016-11-17 14:47:43 +01:00
|
|
|
{
|
|
|
|
|
if (!isDeletable(item)) return false;
|
|
|
|
|
|
|
|
|
|
caf::PdmObject* currentPdmObject = dynamic_cast<caf::PdmObject*>(item);
|
|
|
|
|
if ( !currentPdmObject ) return false;
|
2015-08-11 20:59:05 +02:00
|
|
|
|
2016-11-17 14:47:43 +01:00
|
|
|
caf::PdmChildArrayFieldHandle* childArrayFieldHandle = dynamic_cast<caf::PdmChildArrayFieldHandle*>(currentPdmObject->parentField());
|
|
|
|
|
if ( !childArrayFieldHandle ) return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-11 20:59:05 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RicDeleteItemFeature::onActionTriggered(bool isChecked)
|
|
|
|
|
{
|
2017-05-19 13:40:38 +02:00
|
|
|
std::vector<caf::PdmUiItem*> items;
|
|
|
|
|
caf::SelectionManager::instance()->selectedItems(items);
|
2015-08-11 20:59:05 +02:00
|
|
|
assert(items.size() > 0);
|
|
|
|
|
|
2017-05-19 13:40:38 +02:00
|
|
|
for (caf::PdmUiItem* item: items)
|
2016-11-17 14:47:43 +01:00
|
|
|
{
|
|
|
|
|
if (!isDeletable(item)) continue;
|
2015-08-11 20:59:05 +02:00
|
|
|
|
2016-11-17 14:47:43 +01:00
|
|
|
caf::PdmObject* currentPdmObject = dynamic_cast<caf::PdmObject*>(item);
|
|
|
|
|
if ( !currentPdmObject) continue;
|
2015-08-11 20:59:05 +02:00
|
|
|
|
2016-11-17 14:47:43 +01:00
|
|
|
caf::PdmChildArrayFieldHandle* childArrayFieldHandle = dynamic_cast<caf::PdmChildArrayFieldHandle*>(currentPdmObject->parentField());
|
|
|
|
|
if ( !childArrayFieldHandle) continue;
|
2015-08-11 20:59:05 +02:00
|
|
|
|
2016-11-17 14:47:43 +01:00
|
|
|
int indexAfter = -1;
|
2015-08-11 20:59:05 +02:00
|
|
|
|
2017-05-19 13:40:38 +02:00
|
|
|
std::vector<caf::PdmObjectHandle*> childObjects;
|
2016-11-17 14:47:43 +01:00
|
|
|
childArrayFieldHandle->childObjects(&childObjects);
|
|
|
|
|
|
|
|
|
|
for ( size_t i = 0; i < childObjects.size(); i++ )
|
2015-08-11 20:59:05 +02:00
|
|
|
{
|
2016-11-17 14:47:43 +01:00
|
|
|
if ( childObjects[i] == currentPdmObject )
|
|
|
|
|
{
|
|
|
|
|
indexAfter = static_cast<int>(i);
|
|
|
|
|
}
|
2015-08-11 20:59:05 +02:00
|
|
|
}
|
|
|
|
|
|
2016-11-17 14:47:43 +01:00
|
|
|
// Did not find currently selected pdm object in the current list field
|
|
|
|
|
assert(indexAfter != -1);
|
2015-08-11 20:59:05 +02:00
|
|
|
|
2017-05-19 13:40:38 +02:00
|
|
|
RicDeleteItemExec* executeCmd = new RicDeleteItemExec(caf::SelectionManager::instance()->notificationCenter());
|
2015-08-11 20:59:05 +02:00
|
|
|
|
2016-11-17 14:47:43 +01:00
|
|
|
RicDeleteItemExecData* data = executeCmd->commandData();
|
2017-05-19 13:40:38 +02:00
|
|
|
data->m_rootObject = caf::PdmReferenceHelper::findRoot(childArrayFieldHandle);
|
|
|
|
|
data->m_pathToField = caf::PdmReferenceHelper::referenceFromRootToField(data->m_rootObject, childArrayFieldHandle);
|
2016-11-17 14:47:43 +01:00
|
|
|
data->m_indexToObject = indexAfter;
|
2015-08-11 20:59:05 +02:00
|
|
|
|
|
|
|
|
|
2017-05-19 13:40:38 +02:00
|
|
|
caf::CmdExecCommandManager::instance()->processExecuteCommand(executeCmd);
|
2016-11-17 14:47:43 +01:00
|
|
|
}
|
2015-08-11 20:59:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RicDeleteItemFeature::setupActionLook(QAction* actionToSetup)
|
|
|
|
|
{
|
2015-08-20 17:19:38 +02:00
|
|
|
actionToSetup->setText("Delete");
|
2016-11-18 11:44:12 +01:00
|
|
|
actionToSetup->setIcon(QIcon(":/Erase.png"));
|
2015-08-11 20:59:05 +02:00
|
|
|
}
|