#3090 Add delete of sub items of RimWellPathFractureCollection

This commit is contained in:
Magne Sjaastad 2018-08-02 13:54:36 +02:00
parent 29dd2cd093
commit 2ccdab12c3

View File

@ -1,56 +1,55 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicDeleteSubItemsFeature.h"
#include "RimProject.h"
#include "RimSummaryPlotCollection.h"
#include "RimWellPathCollection.h"
#include "RimWellPathFractureCollection.h"
#include "cafPdmUiItem.h"
#include "cafSelectionManager.h"
#include <QAction>
CAF_CMD_SOURCE_INIT(RicDeleteSubItemsFeature, "RicDeleteSubItemsFeature");
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RicDeleteSubItemsFeature::isCommandEnabled()
bool RicDeleteSubItemsFeature::isCommandEnabled()
{
std::vector<caf::PdmUiItem*> items;
caf::SelectionManager::instance()->selectedItems(items);
if (items.empty()) return false;
for (auto* item : items)
{
if (!RicDeleteSubItemsFeature::hasDeletableSubItems(item)) return false;
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RicDeleteSubItemsFeature::onActionTriggered(bool isChecked)
{
@ -63,27 +62,45 @@ void RicDeleteSubItemsFeature::onActionTriggered(bool isChecked)
{
if (!RicDeleteSubItemsFeature::hasDeletableSubItems(item)) continue;
RimSummaryPlotCollection* summaryPlotColl = dynamic_cast<RimSummaryPlotCollection*>(item);
if (summaryPlotColl)
{
summaryPlotColl->summaryPlots.deleteAllChildObjects();
auto collection = dynamic_cast<RimSummaryPlotCollection*>(item);
if (collection)
{
collection->summaryPlots.deleteAllChildObjects();
summaryPlotColl->updateConnectedEditors();
collection->updateConnectedEditors();
}
}
RimWellPathCollection* wellPathColl = dynamic_cast<RimWellPathCollection*>(item);
if (wellPathColl)
{
wellPathColl->deleteAllWellPaths();
auto collection = dynamic_cast<RimWellPathCollection*>(item);
if (collection)
{
collection->deleteAllWellPaths();
wellPathColl->updateConnectedEditors();
wellPathColl->scheduleRedrawAffectedViews();
collection->updateConnectedEditors();
collection->scheduleRedrawAffectedViews();
}
}
{
auto collection = dynamic_cast<RimWellPathFractureCollection*>(item);
if (collection)
{
collection->deleteFractures();
collection->updateConnectedEditors();
RimProject* proj = nullptr;
collection->firstAncestorOrThisOfType(proj);
if (proj) proj->reloadCompletionTypeResultsInAllViews();
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RicDeleteSubItemsFeature::setupActionLook(QAction* actionToSetup)
{
@ -92,20 +109,32 @@ void RicDeleteSubItemsFeature::setupActionLook(QAction* actionToSetup)
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RicDeleteSubItemsFeature::hasDeletableSubItems(caf::PdmUiItem* uiItem)
{
RimSummaryPlotCollection* summaryPlotColl = dynamic_cast<RimSummaryPlotCollection*>(uiItem);
if (summaryPlotColl && summaryPlotColl->summaryPlots().size() > 0)
{
return true;
auto collection = dynamic_cast<RimSummaryPlotCollection*>(uiItem);
if (collection && !collection->summaryPlots().empty())
{
return true;
}
}
RimWellPathCollection* wellPathColl = dynamic_cast<RimWellPathCollection*>(uiItem);
if (wellPathColl && wellPathColl->wellPaths().size() > 0)
{
return true;
auto collection = dynamic_cast<RimWellPathCollection*>(uiItem);
if (collection && !collection->wellPaths().empty())
{
return true;
}
}
{
auto collection = dynamic_cast<RimWellPathFractureCollection*>(uiItem);
if (collection && !collection->fractures().empty())
{
return true;
}
}
return false;