From c8a784058ed61c79731ef82bb08924e51b9885a1 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 29 Apr 2018 20:26:56 +0100 Subject: [PATCH] Allow duplicating a zone onto the same layer in a GAL canvas. Duplicate already works, so there's little reason to disallow using the zone dialog to do it. The legacy canvas can't be fixed because we'll immediately union the two zones, resulting in a no-op. Fixes: lp:1464677 * https://bugs.launchpad.net/kicad/+bug/1464677 --- pcbnew/tools/pcb_editor_control.cpp | 23 +++++------------------ pcbnew/zones_by_polygon.cpp | 4 ++-- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/pcbnew/tools/pcb_editor_control.cpp b/pcbnew/tools/pcb_editor_control.cpp index 0c10a23cfa..0c89eff089 100644 --- a/pcbnew/tools/pcb_editor_control.cpp +++ b/pcbnew/tools/pcb_editor_control.cpp @@ -796,30 +796,17 @@ int PCB_EDITOR_CONTROL::ZoneDuplicate( const TOOL_EVENT& aEvent ) else success = InvokeNonCopperZonesEditor( m_frame, oldZone, &zoneSettings ); - // If the new zone is on the same layer as the the initial zone, - // do nothing - if( success ) - { - if( oldZone->GetIsKeepout() && ( oldZone->GetLayerSet() == zoneSettings.m_Layers ) ) - { - DisplayError( - m_frame, _( "The duplicated keepout zone cannot be on the same layers as the original zone." ) ); - success = false; - } - else if( !oldZone->GetIsKeepout() && ( oldZone->GetLayer() == zoneSettings.m_CurrentZone_Layer ) ) - { - DisplayError( - m_frame, _( "The duplicated zone cannot be on the same layer as the original zone." ) ); - success = false; - } - } - // duplicate the zone if( success ) { BOARD_COMMIT commit( m_frame ); zoneSettings.ExportSetting( *newZone ); + // If the new zone is on the same layer(s) as the the initial zone, + // offset it a bit so it can more easily be picked. + if( oldZone->GetLayerSet() == zoneSettings.m_Layers ) + newZone->Move( wxPoint( IU_PER_MM, IU_PER_MM ) ); + commit.Add( newZone.release() ); commit.Push( _( "Duplicate zone" ) ); } diff --git a/pcbnew/zones_by_polygon.cpp b/pcbnew/zones_by_polygon.cpp index b999e24ca0..ed347c8995 100644 --- a/pcbnew/zones_by_polygon.cpp +++ b/pcbnew/zones_by_polygon.cpp @@ -129,8 +129,8 @@ void PCB_EDIT_FRAME::duplicateZone( wxDC* aDC, ZONE_CONTAINER* aZone ) else success = InvokeNonCopperZonesEditor( this, aZone, &zoneSettings ); - // If the new zone is on the same layer as the the initial zone, - // do nothing + // If the new zone is on the same layer as the the initial zone we'll end up combining + // them which will result in a no-op. Might as well exit here. if( success ) { if( aZone->GetIsKeepout() && ( aZone->GetLayerSet() == zoneSettings.m_Layers ) )