Pcbnew: fix some issues in GAL when adding holes in zones.
This commit is contained in:
parent
70c961fe6a
commit
9a7abd5914
|
@ -88,7 +88,7 @@ TOOL_ACTION PCB_ACTIONS::drawZone( "pcbnew.InteractiveDrawing.zone",
|
|||
AS_GLOBAL, 0,
|
||||
_( "Add Filled Zone" ), _( "Add a filled zone" ), NULL, AF_ACTIVATE );
|
||||
|
||||
TOOL_ACTION PCB_ACTIONS::drawKeepout( "pcbnew.InteractiveDrawing.keepout",
|
||||
TOOL_ACTION PCB_ACTIONS::drawZoneKeepout( "pcbnew.InteractiveDrawing.keepout",
|
||||
AS_GLOBAL, 0,
|
||||
_( "Add Keepout Area" ), _( "Add a keepout area" ), NULL, AF_ACTIVATE );
|
||||
|
||||
|
@ -650,7 +650,7 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
|
||||
int DRAWING_TOOL::DrawKeepout( const TOOL_EVENT& aEvent )
|
||||
int DRAWING_TOOL::DrawZoneKeepout( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::KEEPOUT );
|
||||
m_frame->SetToolID( ID_PCB_KEEPOUT_AREA_BUTT, wxCURSOR_PENCIL, _( "Add keepout" ) );
|
||||
|
@ -662,7 +662,7 @@ int DRAWING_TOOL::DrawKeepout( const TOOL_EVENT& aEvent )
|
|||
int DRAWING_TOOL::DrawZoneCutout( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ZONE );
|
||||
m_frame->SetToolID( ID_PCB_KEEPOUT_AREA_BUTT, wxCURSOR_PENCIL, _( "Add zone cutout" ) );
|
||||
m_frame->SetToolID( ID_PCB_ZONES_BUTT, wxCURSOR_PENCIL, _( "Add zone cutout" ) );
|
||||
|
||||
return drawZone( false, ZONE_MODE::CUTOUT );
|
||||
}
|
||||
|
@ -671,7 +671,7 @@ int DRAWING_TOOL::DrawZoneCutout( const TOOL_EVENT& aEvent )
|
|||
int DRAWING_TOOL::DrawSimilarZone( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ZONE );
|
||||
m_frame->SetToolID( ID_PCB_KEEPOUT_AREA_BUTT, wxCURSOR_PENCIL, _( "Add similar zone" ) );
|
||||
m_frame->SetToolID( ID_PCB_ZONES_BUTT, wxCURSOR_PENCIL, _( "Add similar zone" ) );
|
||||
|
||||
return drawZone( false, ZONE_MODE::SIMILAR );
|
||||
}
|
||||
|
@ -1334,7 +1334,9 @@ void DRAWING_TOOL::runPolygonEventLoop( POLYGON_GEOM_MANAGER& polyGeomMgr )
|
|||
|
||||
int DRAWING_TOOL::drawZone( bool aKeepout, ZONE_MODE aMode )
|
||||
{
|
||||
// get a source zone, if we need one
|
||||
// get a source zone, if we need one. We need it for:
|
||||
// ZONE_MODE::CUTOUT (adding a hole to the source zone)
|
||||
// ZONE_MODE::SIMILAR (creating a new zone using settings of source zone
|
||||
ZONE_CONTAINER* sourceZone = nullptr;
|
||||
|
||||
if( !getSourceZoneForAction( aMode, sourceZone ) )
|
||||
|
@ -1398,7 +1400,7 @@ void DRAWING_TOOL::SetTransitions()
|
|||
Go( &DRAWING_TOOL::DrawArc, PCB_ACTIONS::drawArc.MakeEvent() );
|
||||
Go( &DRAWING_TOOL::DrawDimension, PCB_ACTIONS::drawDimension.MakeEvent() );
|
||||
Go( &DRAWING_TOOL::DrawZone, PCB_ACTIONS::drawZone.MakeEvent() );
|
||||
Go( &DRAWING_TOOL::DrawKeepout, PCB_ACTIONS::drawKeepout.MakeEvent() );
|
||||
Go( &DRAWING_TOOL::DrawZoneKeepout, PCB_ACTIONS::drawZoneKeepout.MakeEvent() );
|
||||
Go( &DRAWING_TOOL::DrawZoneCutout, PCB_ACTIONS::drawZoneCutout.MakeEvent() );
|
||||
Go( &DRAWING_TOOL::DrawSimilarZone, PCB_ACTIONS::drawSimilarZone.MakeEvent() );
|
||||
Go( &DRAWING_TOOL::PlaceText, PCB_ACTIONS::placeText.MakeEvent() );
|
||||
|
|
|
@ -136,13 +136,13 @@ public:
|
|||
int DrawZone( const TOOL_EVENT& aEvent );
|
||||
|
||||
/**
|
||||
* Function DrawKeepout()
|
||||
* Function DrawZoneKeepout()
|
||||
* Starts interactively drawing a keepout area. After invoking the function an area settings
|
||||
* dialog is displayed. After confirmation it allows the user to set points that are going to
|
||||
* be used as a boundary polygon of the area. Double click or clicking on the origin of the
|
||||
* boundary polyline finishes the drawing.
|
||||
*/
|
||||
int DrawKeepout( const TOOL_EVENT& aEvent );
|
||||
int DrawZoneKeepout( const TOOL_EVENT& aEvent );
|
||||
|
||||
/**
|
||||
* Function DrawZoneCutout()
|
||||
|
@ -212,7 +212,10 @@ private:
|
|||
*
|
||||
* @param aKeepout dictates if the drawn polygon is a zone or a
|
||||
* keepout area.
|
||||
* @param aMode dictates the mode of the zone tool
|
||||
* @param aMode dictates the mode of the zone tool:
|
||||
* ADD add a new zone/keepout with fresh settings
|
||||
* CUTOUT add a cutout to an existing zone
|
||||
* SIMILAR add a new zone with the same settings as an existing one
|
||||
*/
|
||||
int drawZone( bool aKeepout, ZONE_MODE aMode );
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ boost::optional<TOOL_EVENT> PCB_ACTIONS::TranslateLegacyId( int aId )
|
|||
return PCB_ACTIONS::drawZone.MakeEvent();
|
||||
|
||||
case ID_PCB_KEEPOUT_AREA_BUTT:
|
||||
return PCB_ACTIONS::drawKeepout.MakeEvent();
|
||||
return PCB_ACTIONS::drawZoneKeepout.MakeEvent();
|
||||
|
||||
case ID_PCB_ADD_LINE_BUTT:
|
||||
case ID_MODEDIT_LINE_TOOL:
|
||||
|
|
|
@ -134,7 +134,7 @@ public:
|
|||
static TOOL_ACTION drawZone;
|
||||
|
||||
/// Activation of the drawing tool (drawing a keepout area)
|
||||
static TOOL_ACTION drawKeepout;
|
||||
static TOOL_ACTION drawZoneKeepout;
|
||||
|
||||
/// Activation of the drawing tool (drawing a ZONE cutout)
|
||||
static TOOL_ACTION drawZoneCutout;
|
||||
|
|
|
@ -107,33 +107,26 @@ std::unique_ptr<ZONE_CONTAINER> ZONE_CREATE_HELPER::createZoneFromExisting(
|
|||
void ZONE_CREATE_HELPER::performZoneCutout( ZONE_CONTAINER& aExistingZone,
|
||||
ZONE_CONTAINER& aCutout )
|
||||
{
|
||||
auto& board = *m_tool.getModel<BOARD>();
|
||||
auto& toolMgr = *m_tool.GetManager();
|
||||
BOARD* board = m_tool.getModel<BOARD>();
|
||||
int curr_hole = aExistingZone.Outline()->NewHole( 0 );
|
||||
|
||||
aExistingZone.Outline()->NewOutline();
|
||||
|
||||
// Copy cutout corners into existing zone
|
||||
// Copy cutout corners into existing zone, in the new hole
|
||||
for( int ii = 0; ii < aCutout.GetNumCorners(); ii++ )
|
||||
{
|
||||
aExistingZone.Outline()->Append( aCutout.GetCornerPosition( ii ) );
|
||||
aExistingZone.Outline()->Append( aCutout.GetCornerPosition( ii ), 0, curr_hole );
|
||||
}
|
||||
|
||||
// Close the current corner list
|
||||
aExistingZone.Outline()->Outline( 0 ).SetClosed( true );
|
||||
// Be sure the current corner list is closed
|
||||
aExistingZone.Outline()->Hole( 0, curr_hole ).SetClosed( true );
|
||||
|
||||
board.OnAreaPolygonModified( nullptr, &aExistingZone );
|
||||
// Combine holes and simplify the new outline:
|
||||
board->OnAreaPolygonModified( nullptr, &aExistingZone );
|
||||
|
||||
// Re-fill if needed
|
||||
if( aExistingZone.IsFilled() )
|
||||
{
|
||||
SELECTION_TOOL* selTool = toolMgr.GetTool<SELECTION_TOOL>();
|
||||
|
||||
auto& selection = selTool->GetSelection();
|
||||
|
||||
selection.Clear();
|
||||
selection.Add( &aExistingZone );
|
||||
|
||||
toolMgr.RunAction( PCB_ACTIONS::zoneFill, true );
|
||||
PCB_EDIT_FRAME* frame = m_tool.getEditFrame<PCB_EDIT_FRAME>();
|
||||
frame->Fill_Zone( &aExistingZone );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,23 +135,24 @@ void ZONE_CREATE_HELPER::commitZone( std::unique_ptr<ZONE_CONTAINER> aZone )
|
|||
{
|
||||
auto& frame = *m_tool.getEditFrame<PCB_EDIT_FRAME>();
|
||||
|
||||
if( !m_params.m_keepout )
|
||||
frame.Fill_Zone( aZone.get() );
|
||||
|
||||
BOARD_COMMIT bCommit( &m_tool );
|
||||
|
||||
if( m_params.m_mode == DRAWING_TOOL::ZONE_MODE::CUTOUT )
|
||||
{
|
||||
// For cutouts, subtract from the source
|
||||
bCommit.Modify( m_params.m_sourceZone );
|
||||
|
||||
performZoneCutout( *m_params.m_sourceZone, *aZone );
|
||||
|
||||
bCommit.Push( _( "Add a zone cutout" ) );
|
||||
m_params.m_sourceZone->Hatch();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add the zone as a new board item
|
||||
aZone->Hatch();
|
||||
|
||||
if( !m_params.m_keepout )
|
||||
frame.Fill_Zone( aZone.get() );
|
||||
|
||||
bCommit.Add( aZone.release() );
|
||||
bCommit.Push( _( "Add a zone" ) );
|
||||
}
|
||||
|
@ -170,7 +164,6 @@ bool ZONE_CREATE_HELPER::OnFirstPoint()
|
|||
// if we don't have a zone, create one
|
||||
// the user's choice here can affect things like the colour
|
||||
// of the preview
|
||||
|
||||
if( !m_zone )
|
||||
{
|
||||
if( m_params.m_sourceZone )
|
||||
|
@ -219,6 +212,8 @@ void ZONE_CREATE_HELPER::OnComplete( const POLYGON_GEOM_MANAGER& aMgr )
|
|||
}
|
||||
else
|
||||
{
|
||||
// if m_params.m_mode == DRAWING_TOOL::ZONE_MODE::CUTOUT, m_zone
|
||||
// will be merged to the existing zone as a new hole.
|
||||
m_zone->Outline()->NewOutline();
|
||||
|
||||
for( const auto& pt : finalPoints )
|
||||
|
@ -228,7 +223,6 @@ void ZONE_CREATE_HELPER::OnComplete( const POLYGON_GEOM_MANAGER& aMgr )
|
|||
|
||||
m_zone->Outline()->Outline( 0 ).SetClosed( true );
|
||||
m_zone->Outline()->RemoveNullSegments();
|
||||
m_zone->Hatch();
|
||||
|
||||
// hand the zone over to the committer
|
||||
commitZone( std::move( m_zone ) );
|
||||
|
|
Loading…
Reference in New Issue