pcbnew: Fix zone cutout duplication
When creating the zone cutout, we delete the old zone and add a new one with each cutout. This requires resetting the source zone and clearing our previous selection if we would like to continue using the cutout tool on the new zone. Fixes: lp:1812339 * https://bugs.launchpad.net/kicad/+bug/1812339
This commit is contained in:
parent
56879a964b
commit
efe880bb79
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* This program source code file is part of KICAD, a free EDA CAD application.
|
* This program source code file is part of KICAD, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017 Kicad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 2017-2019 Kicad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014-2017 CERN
|
* Copyright (C) 2014-2017 CERN
|
||||||
* Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 2018-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
|
@ -1431,7 +1431,6 @@ int DRAWING_TOOL::drawZone( bool aKeepout, ZONE_MODE aMode )
|
||||||
polyGeomMgr.SetFinished();
|
polyGeomMgr.SetFinished();
|
||||||
polyGeomMgr.Reset();
|
polyGeomMgr.Reset();
|
||||||
|
|
||||||
// ready to start again
|
|
||||||
started = false;
|
started = false;
|
||||||
m_controls->SetAutoPan( false );
|
m_controls->SetAutoPan( false );
|
||||||
m_controls->CaptureCursor( false );
|
m_controls->CaptureCursor( false );
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
* Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors.
|
*
|
||||||
|
* Copyright (C) 2017-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -36,7 +37,7 @@
|
||||||
|
|
||||||
#include <zone_filler.h>
|
#include <zone_filler.h>
|
||||||
|
|
||||||
ZONE_CREATE_HELPER::ZONE_CREATE_HELPER( DRAWING_TOOL& aTool, const PARAMS& aParams ):
|
ZONE_CREATE_HELPER::ZONE_CREATE_HELPER( DRAWING_TOOL& aTool, PARAMS& aParams ):
|
||||||
m_tool( aTool ),
|
m_tool( aTool ),
|
||||||
m_params( aParams ),
|
m_params( aParams ),
|
||||||
m_parentView( *aTool.getView() )
|
m_parentView( *aTool.getView() )
|
||||||
|
@ -119,6 +120,10 @@ void ZONE_CREATE_HELPER::performZoneCutout( ZONE_CONTAINER& aZone, ZONE_CONTAINE
|
||||||
BOARD* board = m_tool.getModel<BOARD>();
|
BOARD* board = m_tool.getModel<BOARD>();
|
||||||
std::vector<ZONE_CONTAINER*> newZones;
|
std::vector<ZONE_CONTAINER*> newZones;
|
||||||
|
|
||||||
|
// Clear the selection before removing the old zone
|
||||||
|
auto toolMgr = m_tool.GetManager();
|
||||||
|
toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
|
|
||||||
SHAPE_POLY_SET originalOutline( *aZone.Outline() );
|
SHAPE_POLY_SET originalOutline( *aZone.Outline() );
|
||||||
originalOutline.BooleanSubtract( *aCutout.Outline(), SHAPE_POLY_SET::PM_FAST );
|
originalOutline.BooleanSubtract( *aCutout.Outline(), SHAPE_POLY_SET::PM_FAST );
|
||||||
|
|
||||||
|
@ -146,10 +151,10 @@ void ZONE_CREATE_HELPER::performZoneCutout( ZONE_CONTAINER& aZone, ZONE_CONTAINE
|
||||||
ZONE_FILLER filler( board );
|
ZONE_FILLER filler( board );
|
||||||
filler.Fill( newZones );
|
filler.Fill( newZones );
|
||||||
|
|
||||||
auto toolMgr = m_tool.GetManager();
|
// Select the new zone and set it as the source for the next cutout
|
||||||
|
|
||||||
toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
|
||||||
toolMgr->RunAction( PCB_ACTIONS::selectItem, true, newZones[0] );
|
toolMgr->RunAction( PCB_ACTIONS::selectItem, true, newZones[0] );
|
||||||
|
m_params.m_sourceZone = newZones[0];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -295,6 +300,7 @@ void ZONE_CREATE_HELPER::OnComplete( const POLYGON_GEOM_MANAGER& aMgr )
|
||||||
|
|
||||||
// hand the zone over to the committer
|
// hand the zone over to the committer
|
||||||
commitZone( std::move( m_zone ) );
|
commitZone( std::move( m_zone ) );
|
||||||
|
m_zone = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_parentView.SetVisible( &m_previewItem, false );
|
m_parentView.SetVisible( &m_previewItem, false );
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017 Kicad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 2017-2019 Kicad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -66,7 +66,7 @@ public:
|
||||||
* @param aTool the DRAWING_TOOL to provide the zone tool to
|
* @param aTool the DRAWING_TOOL to provide the zone tool to
|
||||||
* @param aParams the parameters to use to guide the zone creation
|
* @param aParams the parameters to use to guide the zone creation
|
||||||
*/
|
*/
|
||||||
ZONE_CREATE_HELPER( DRAWING_TOOL& aTool, const PARAMS& aParams );
|
ZONE_CREATE_HELPER( DRAWING_TOOL& aTool, PARAMS& aParams );
|
||||||
|
|
||||||
~ZONE_CREATE_HELPER();
|
~ZONE_CREATE_HELPER();
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ private:
|
||||||
DRAWING_TOOL& m_tool;
|
DRAWING_TOOL& m_tool;
|
||||||
|
|
||||||
///> Parameters of the zone to be drawn
|
///> Parameters of the zone to be drawn
|
||||||
const PARAMS& m_params;
|
PARAMS& m_params;
|
||||||
|
|
||||||
///> The preview item to display
|
///> The preview item to display
|
||||||
KIGFX::PREVIEW::POLYGON_ITEM m_previewItem;
|
KIGFX::PREVIEW::POLYGON_ITEM m_previewItem;
|
||||||
|
|
Loading…
Reference in New Issue