kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #28250
Re: [PATCH] Undo/redo points for zone fill actions (GAL)
Hi,
Sorry, that patch had a dependency on a previous commit in my patch stack.
Here's an updated one. PCB_EDITOR_CONTROL now inherits PCB_TOOL, not
TOOL_INTERACTIVE, so it can use the relevant BOARD_COMMIT constructor.
Cheers,
John
On Sat, Feb 25, 2017 at 2:50 PM, John Beard <john.j.beard@xxxxxxxxx> wrote:
> 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 e30af04456d1607e69f21afddce0b2b170bd6d2c 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] 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 | 30 +++++++++++++++++++++++++++++-
pcbnew/tools/pcb_editor_control.h | 4 ++--
2 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/pcbnew/tools/pcb_editor_control.cpp b/pcbnew/tools/pcb_editor_control.cpp
index 7be6dcd4e..b9b95bde9 100644
--- a/pcbnew/tools/pcb_editor_control.cpp
+++ b/pcbnew/tools/pcb_editor_control.cpp
@@ -228,7 +228,7 @@ public:
PCB_EDITOR_CONTROL::PCB_EDITOR_CONTROL() :
- TOOL_INTERACTIVE( "pcbnew.EditorControl" ),
+ PCB_TOOL( "pcbnew.EditorControl" ),
m_frame( nullptr )
{
m_placeOrigin = new KIGFX::ORIGIN_VIEWITEM( KIGFX::COLOR4D( 0.8, 0.0, 0.0, 1.0 ),
@@ -645,17 +645,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;
@@ -667,15 +674,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;
@@ -688,17 +702,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;
@@ -710,15 +731,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;
diff --git a/pcbnew/tools/pcb_editor_control.h b/pcbnew/tools/pcb_editor_control.h
index 3684a1b1e..5f8ba280b 100644
--- a/pcbnew/tools/pcb_editor_control.h
+++ b/pcbnew/tools/pcb_editor_control.h
@@ -25,7 +25,7 @@
#ifndef PCB_EDITOR_CONTROL_H
#define PCB_EDITOR_CONTROL_H
-#include <tool/tool_interactive.h>
+#include <tools/pcb_tool.h>
namespace KIGFX {
class ORIGIN_VIEWITEM;
@@ -38,7 +38,7 @@ class PCB_EDIT_FRAME;
*
* Handles actions specific to the board editor in pcbnew.
*/
-class PCB_EDITOR_CONTROL : public TOOL_INTERACTIVE
+class PCB_EDITOR_CONTROL : public PCB_TOOL
{
public:
PCB_EDITOR_CONTROL();
--
2.11.0
Follow ups
References