Add "Delete All Polygons" from the polygon collection

This commit is contained in:
Magne Sjaastad
2025-02-19 18:21:15 +01:00
parent 7a82c2f145
commit 0b6578bcb2
5 changed files with 98 additions and 0 deletions

View File

@@ -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})

View File

@@ -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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicDeleteAllPolygonsFeature.h"
#include "Polygons/RimPolygonCollection.h"
#include "RimOilField.h"
#include "RimProject.h"
#include <QAction>
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" ) );
}

View File

@@ -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 <http://www.gnu.org/licenses/gpl.html>
// 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;
};

View File

@@ -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";
}
//--------------------------------------------------------------------------------------------------

View File

@@ -40,6 +40,7 @@ public:
RimPolygon* appendUserDefinedPolygon();
void addUserDefinedPolygon( RimPolygon* polygon );
void deleteUserDefinedPolygons();
void deleteAllPolygons();
void addPolygonFile( RimPolygonFile* polygonFile );