← Back to team overview

kicad-developers team mailing list archive

[PATCH] Undo/redo points for zone fill actions (GAL)

 

Hi,

Thiis is a patch to allow the zone fill/unfill actions to get undo and
redo points in GAL.

These functions could do with a refactor, perhaps, but this commit
doesn't attempt that, in order to keep the change clear.

Legacy doesn't have this function either, but once GAL makes the
points, legacy can use them as normal.

Cheers,

John
From d9d18cd02e54ac3098e5b3ca7af667aeed3ef46b Mon Sep 17 00:00:00 2001
From: John Beard <john.j.beard@xxxxxxxxx>
Date: Fri, 24 Feb 2017 20:26:43 +0800
Subject: [PATCH 1/4] When filling/unfilling zones, create undo points in GAL

This is a feature which is apparently not available in legacy, but the
undo points created in GAL do work in legacy mode.
---
 pcbnew/tools/pcb_editor_control.cpp | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/pcbnew/tools/pcb_editor_control.cpp b/pcbnew/tools/pcb_editor_control.cpp
index 76d118e7a..68692a79f 100644
--- a/pcbnew/tools/pcb_editor_control.cpp
+++ b/pcbnew/tools/pcb_editor_control.cpp
@@ -573,17 +573,24 @@ int PCB_EDITOR_CONTROL::ZoneFill( const TOOL_EVENT& aEvent )
     const auto& selection = selTool->GetSelection();
     RN_DATA* ratsnest = getModel<BOARD>()->GetRatsnest();
 
+    BOARD_COMMIT commit( this );
+
     for( auto item : selection )
     {
         assert( item->Type() == PCB_ZONE_AREA_T );
 
         ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*> ( item );
+
+        commit.Modify( zone );
+
         m_frame->Fill_Zone( zone );
         zone->SetIsFilled( true );
         ratsnest->Update( zone );
         getView()->Update( zone );
     }
 
+    commit.Push( _( "Fill Zone" ) );
+
     ratsnest->Recalculate();
 
     return 0;
@@ -595,15 +602,22 @@ int PCB_EDITOR_CONTROL::ZoneFillAll( const TOOL_EVENT& aEvent )
     BOARD* board = getModel<BOARD>();
     RN_DATA* ratsnest = board->GetRatsnest();
 
+    BOARD_COMMIT commit( this );
+
     for( int i = 0; i < board->GetAreaCount(); ++i )
     {
         ZONE_CONTAINER* zone = board->GetArea( i );
+
+        commit.Modify( zone );
+
         m_frame->Fill_Zone( zone );
         zone->SetIsFilled( true );
         ratsnest->Update( zone );
         getView()->Update( zone );
     }
 
+    commit.Push( _( "Fill All Zones" ) );
+
     ratsnest->Recalculate();
 
     return 0;
@@ -616,17 +630,24 @@ int PCB_EDITOR_CONTROL::ZoneUnfill( const TOOL_EVENT& aEvent )
     const auto& selection = selTool->GetSelection();
     RN_DATA* ratsnest = getModel<BOARD>()->GetRatsnest();
 
+    BOARD_COMMIT commit( this );
+
     for( auto item : selection )
     {
         assert( item->Type() == PCB_ZONE_AREA_T );
 
         ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*>( item );
+
+        commit.Modify( zone );
+
         zone->SetIsFilled( false );
         zone->ClearFilledPolysList();
         ratsnest->Update( zone );
         getView()->Update( zone );
     }
 
+    commit.Push( _( "Unfill Zone" ) );
+
     ratsnest->Recalculate();
 
     return 0;
@@ -638,15 +659,22 @@ int PCB_EDITOR_CONTROL::ZoneUnfillAll( const TOOL_EVENT& aEvent )
     BOARD* board = getModel<BOARD>();
     RN_DATA* ratsnest = board->GetRatsnest();
 
+    BOARD_COMMIT commit( this );
+
     for( int i = 0; i < board->GetAreaCount(); ++i )
     {
         ZONE_CONTAINER* zone = board->GetArea( i );
+
+        commit.Modify( zone );
+
         zone->SetIsFilled( false );
         zone->ClearFilledPolysList();
         ratsnest->Update( zone );
         getView()->Update( zone );
     }
 
+    commit.Push( _( "Unfill All Zones" ) );
+
     ratsnest->Recalculate();
 
     return 0;
-- 
2.11.0


Follow ups