From a0df0f7f0685cd6f5160d5ecc81539a43d4be266 Mon Sep 17 00:00:00 2001 From: John Beard 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 7be6dcd4e4..b9b95bde91 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()->GetRatsnest(); + BOARD_COMMIT commit( this ); + for( auto item : selection ) { assert( item->Type() == PCB_ZONE_AREA_T ); ZONE_CONTAINER* zone = static_cast ( 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(); 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()->GetRatsnest(); + BOARD_COMMIT commit( this ); + for( auto item : selection ) { assert( item->Type() == PCB_ZONE_AREA_T ); ZONE_CONTAINER* zone = static_cast( 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(); 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 3684a1b1ea..5f8ba280b7 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 +#include 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();