diff --git a/ApplicationLibCode/Commands/PolygonCommands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/PolygonCommands/CMakeLists_files.cmake index d6cdc20066..f4bbb446ac 100644 --- a/ApplicationLibCode/Commands/PolygonCommands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/PolygonCommands/CMakeLists_files.cmake @@ -7,6 +7,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RicExportPolygonPolFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicSimplifyPolygonFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicBasicPolygonFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicDeleteAllPolygonsFeature.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -18,6 +19,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RicExportPolygonPolFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicSimplifyPolygonFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicBasicPolygonFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicDeleteAllPolygonsFeature.cpp ) list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/Commands/PolygonCommands/RicDeleteAllPolygonsFeature.cpp b/ApplicationLibCode/Commands/PolygonCommands/RicDeleteAllPolygonsFeature.cpp new file mode 100644 index 0000000000..4353aeb84f --- /dev/null +++ b/ApplicationLibCode/Commands/PolygonCommands/RicDeleteAllPolygonsFeature.cpp @@ -0,0 +1,48 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2025 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicDeleteAllPolygonsFeature.h" + +#include "Polygons/RimPolygonCollection.h" +#include "RimOilField.h" +#include "RimProject.h" + +#include + +CAF_CMD_SOURCE_INIT( RicDeleteAllPolygonsFeature, "RicDeleteAllPolygonsFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicDeleteAllPolygonsFeature::onActionTriggered( bool isChecked ) +{ + auto proj = RimProject::current(); + auto polygonCollection = proj->activeOilField()->polygonCollection(); + + polygonCollection->deleteAllPolygons(); + polygonCollection->updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicDeleteAllPolygonsFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "Delete All Polygons" ); + actionToSetup->setIcon( QIcon( ":/Erase.png" ) ); +} diff --git a/ApplicationLibCode/Commands/PolygonCommands/RicDeleteAllPolygonsFeature.h b/ApplicationLibCode/Commands/PolygonCommands/RicDeleteAllPolygonsFeature.h new file mode 100644 index 0000000000..855cad4a9d --- /dev/null +++ b/ApplicationLibCode/Commands/PolygonCommands/RicDeleteAllPolygonsFeature.h @@ -0,0 +1,33 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2025 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicDeleteAllPolygonsFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.cpp b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.cpp index d61a608734..36eb785bdc 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.cpp @@ -100,6 +100,18 @@ void RimPolygonCollection::deleteUserDefinedPolygons() scheduleRedrawViews(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPolygonCollection::deleteAllPolygons() +{ + m_polygons().deleteChildren(); + m_polygonFiles().deleteChildren(); + + updateViewTreeItems(); + scheduleRedrawViews(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -184,6 +196,8 @@ void RimPolygonCollection::childFieldChangedByUi( const caf::PdmFieldHandle* cha void RimPolygonCollection::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const { RimPolygonCollection::appendPolygonMenuItems( menuBuilder ); + menuBuilder.addSeparator(); + menuBuilder << "RicDeleteAllPolygonsFeature"; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.h b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.h index 3c0b163582..126bf80480 100644 --- a/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Polygons/RimPolygonCollection.h @@ -40,6 +40,7 @@ public: RimPolygon* appendUserDefinedPolygon(); void addUserDefinedPolygon( RimPolygon* polygon ); void deleteUserDefinedPolygons(); + void deleteAllPolygons(); void addPolygonFile( RimPolygonFile* polygonFile );