mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
New feature: delete unchecked subitems (#9010)
* New feature: delete unchecked subitems
This commit is contained in:
@@ -29,7 +29,6 @@ set(SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/Ric3dViewPickEventHandler.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicContourMapPickEventHandler.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicVec3dPickEventHandler.h
|
||||
# General delete of any object in a child array field
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeleteItemExec.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeleteItemExecData.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeleteItemFeature.h
|
||||
@@ -85,6 +84,7 @@ set(SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicCalculatorWidgetCreator.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicUserDefinedCalculatorUi.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicShowDataSourcesForRealization.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeleteUncheckedSubItemsFeature.h
|
||||
)
|
||||
|
||||
set(SOURCE_GROUP_SOURCE_FILES
|
||||
@@ -117,7 +117,6 @@ set(SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/Ric3dViewPickEventHandler.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicContourMapPickEventHandler.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicVec3dPickEventHandler.cpp
|
||||
# General delete of any object in a child array field
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeleteItemExec.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeleteItemExecData.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeleteItemFeature.cpp
|
||||
@@ -173,6 +172,7 @@ set(SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicCalculatorWidgetCreator.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicUserDefinedCalculatorUi.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicShowDataSourcesForRealization.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeleteUncheckedSubItemsFeature.cpp
|
||||
)
|
||||
|
||||
if(RESINSIGHT_USE_QT_CHARTS)
|
||||
|
||||
@@ -21,7 +21,9 @@
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryMultiPlot.h"
|
||||
#include "RimSummaryMultiPlotCollection.h"
|
||||
#include "RimWellPath.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
#include "RimWellPathFracture.h"
|
||||
#include "RimWellPathFractureCollection.h"
|
||||
|
||||
#include "cafPdmUiItem.h"
|
||||
@@ -35,6 +37,14 @@ CAF_CMD_SOURCE_INIT( RicDeleteSubItemsFeature, "RicDeleteSubItemsFeature" );
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicDeleteSubItemsFeature::isCommandEnabled()
|
||||
{
|
||||
return RicDeleteSubItemsFeature::canCommandBeEnabled();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicDeleteSubItemsFeature::canCommandBeEnabled()
|
||||
{
|
||||
std::vector<caf::PdmUiItem*> items;
|
||||
caf::SelectionManager::instance()->selectedItems( items );
|
||||
@@ -54,60 +64,8 @@ bool RicDeleteSubItemsFeature::isCommandEnabled()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicDeleteSubItemsFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
std::vector<caf::PdmUiItem*> items;
|
||||
caf::SelectionManager::instance()->selectedItems( items );
|
||||
|
||||
CVF_ASSERT( items.size() > 0 );
|
||||
|
||||
for ( auto item : items )
|
||||
{
|
||||
if ( !RicDeleteSubItemsFeature::hasDeletableSubItems( item ) ) continue;
|
||||
|
||||
{
|
||||
auto multiPlot = dynamic_cast<RimSummaryMultiPlot*>( item );
|
||||
if ( multiPlot )
|
||||
{
|
||||
multiPlot->deleteAllPlots();
|
||||
|
||||
multiPlot->updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
auto collection = dynamic_cast<RimSummaryMultiPlotCollection*>( item );
|
||||
if ( collection )
|
||||
{
|
||||
collection->deleteAllPlots();
|
||||
|
||||
collection->updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
auto collection = dynamic_cast<RimWellPathCollection*>( item );
|
||||
if ( collection )
|
||||
{
|
||||
collection->deleteAllWellPaths();
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
bool onlyUnchecked = false;
|
||||
RicDeleteSubItemsFeature::deleteSubItems( onlyUnchecked );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -159,3 +117,116 @@ bool RicDeleteSubItemsFeature::hasDeletableSubItems( caf::PdmUiItem* uiItem )
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicDeleteSubItemsFeature::deleteSubItems( bool onlyDeleteUnchecked )
|
||||
{
|
||||
std::vector<caf::PdmUiItem*> items;
|
||||
caf::SelectionManager::instance()->selectedItems( items );
|
||||
|
||||
CVF_ASSERT( items.size() > 0 );
|
||||
|
||||
for ( auto item : items )
|
||||
{
|
||||
if ( !RicDeleteSubItemsFeature::hasDeletableSubItems( item ) ) continue;
|
||||
|
||||
{
|
||||
auto multiPlot = dynamic_cast<RimSummaryMultiPlot*>( item );
|
||||
if ( multiPlot )
|
||||
{
|
||||
if ( onlyDeleteUnchecked )
|
||||
{
|
||||
auto plots = multiPlot->plots();
|
||||
for ( auto plot : plots )
|
||||
{
|
||||
if ( plot->showWindow() ) continue;
|
||||
multiPlot->removePlotNoUpdate( plot );
|
||||
delete plot;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
multiPlot->deleteAllPlots();
|
||||
}
|
||||
|
||||
multiPlot->updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
auto collection = dynamic_cast<RimSummaryMultiPlotCollection*>( item );
|
||||
if ( collection )
|
||||
{
|
||||
if ( onlyDeleteUnchecked )
|
||||
{
|
||||
auto plots = collection->multiPlots();
|
||||
for ( auto plot : plots )
|
||||
{
|
||||
if ( plot->showWindow() ) continue;
|
||||
collection->removePlotNoUpdate( plot );
|
||||
delete plot;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
collection->deleteAllPlots();
|
||||
}
|
||||
|
||||
collection->updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
auto collection = dynamic_cast<RimWellPathCollection*>( item );
|
||||
if ( collection )
|
||||
{
|
||||
if ( onlyDeleteUnchecked )
|
||||
{
|
||||
auto paths = collection->allWellPaths();
|
||||
for ( auto path : paths )
|
||||
{
|
||||
if ( path->showWellPath() ) continue;
|
||||
collection->removeWellPath( path );
|
||||
delete path;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
collection->deleteAllWellPaths();
|
||||
}
|
||||
|
||||
collection->updateConnectedEditors();
|
||||
collection->scheduleRedrawAffectedViews();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
auto collection = dynamic_cast<RimWellPathFractureCollection*>( item );
|
||||
if ( collection )
|
||||
{
|
||||
if ( onlyDeleteUnchecked )
|
||||
{
|
||||
auto items = collection->allFractures();
|
||||
for ( auto item : items )
|
||||
{
|
||||
if ( item->isChecked() ) continue;
|
||||
collection->removeFracture( item );
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
collection->deleteFractures();
|
||||
}
|
||||
|
||||
collection->updateConnectedEditors();
|
||||
|
||||
RimProject* proj = nullptr;
|
||||
collection->firstAncestorOrThisOfType( proj );
|
||||
if ( proj ) proj->reloadCompletionTypeResultsInAllViews();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,11 +32,13 @@ class RicDeleteSubItemsFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
public:
|
||||
static bool hasDeletableSubItems( caf::PdmUiItem* uiItem );
|
||||
static void deleteSubItems( bool onlyDeleteUnchecked );
|
||||
static bool canCommandBeEnabled();
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
private:
|
||||
static bool hasDeletableSubItems( caf::PdmUiItem* uiItem );
|
||||
};
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2022 Equinor 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 "RicDeleteUncheckedSubItemsFeature.h"
|
||||
|
||||
#include "RicDeleteSubItemsFeature.h"
|
||||
|
||||
#include "cafPdmUiItem.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicDeleteUncheckedSubItemsFeature, "RicDeleteUncheckedSubItemsFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicDeleteUncheckedSubItemsFeature::isCommandEnabled()
|
||||
{
|
||||
return RicDeleteSubItemsFeature::canCommandBeEnabled();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicDeleteUncheckedSubItemsFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
bool onlyUnchecked = true;
|
||||
RicDeleteSubItemsFeature::deleteSubItems( onlyUnchecked );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicDeleteUncheckedSubItemsFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText( "Delete Unchecked Sub Items" );
|
||||
actionToSetup->setIcon( QIcon( ":/Erase.svg" ) );
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2022 Equinor 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
namespace caf
|
||||
{
|
||||
class PdmUiItem;
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicDeleteUncheckedSubItemsFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
||||
@@ -64,6 +64,14 @@ void RimWellPathFractureCollection::addFracture( RimWellPathFracture* fracture )
|
||||
m_fractures.push_back( fracture );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellPathFractureCollection::removeFracture( RimWellPathFracture* fracture )
|
||||
{
|
||||
m_fractures.removeChild( fracture );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -43,6 +43,7 @@ public:
|
||||
|
||||
bool hasFractures() const;
|
||||
void addFracture( RimWellPathFracture* fracture );
|
||||
void removeFracture( RimWellPathFracture* fracture );
|
||||
void deleteFractures();
|
||||
|
||||
std::vector<RimWellPathFracture*> allFractures() const;
|
||||
|
||||
@@ -1305,6 +1305,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
if ( caf::CmdFeatureManager::instance()->getCommandFeature( "RicDeleteSubItemsFeature" )->canFeatureBeExecuted() )
|
||||
{
|
||||
menuBuilder << "Separator";
|
||||
menuBuilder << "RicDeleteUncheckedSubItemsFeature";
|
||||
menuBuilder << "RicDeleteSubItemsFeature";
|
||||
}
|
||||
|
||||
|
||||
@@ -83,6 +83,15 @@ void RimSummaryMultiPlotCollection::addSummaryMultiPlot( RimSummaryMultiPlot* pl
|
||||
plot->duplicatePlot.connect( this, &RimSummaryMultiPlotCollection::onDuplicatePlot );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryMultiPlotCollection::removePlotNoUpdate( RimSummaryMultiPlot* plot )
|
||||
{
|
||||
if ( plot == nullptr ) return;
|
||||
m_summaryMultiPlots().removeChild( plot );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -48,6 +48,7 @@ public:
|
||||
void addSummaryMultiPlot( RimSummaryMultiPlot* plot );
|
||||
void summaryPlotItemInfos( QList<caf::PdmOptionItemInfo>* optionInfos ) const;
|
||||
void duplicatePlot( RimSummaryMultiPlot* plotToDuplicate );
|
||||
void removePlotNoUpdate( RimSummaryMultiPlot* plotToRemove );
|
||||
|
||||
void updateSummaryNameHasChanged();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user