Browse Source

pcbnew: Handle SEGZONE in GAL

SEGZONEs are no longer created by pcbnew but may exist in older boards.
This allows deleting the old fills in a manner similar to the deletion
in Legacy canvas.

Fixes: lp:1794571
* https://bugs.launchpad.net/kicad/+bug/1794571
pull/13/head
Seth Hillbrand 7 years ago
parent
commit
ef6f7e96f3
  1. 1
      pcbnew/tools/pcb_actions.h
  2. 2
      pcbnew/tools/pcb_editor_control.cpp
  3. 33
      pcbnew/tools/zone_filler_tool.cpp
  4. 3
      pcbnew/tools/zone_filler_tool.h

1
pcbnew/tools/pcb_actions.h

@ -299,6 +299,7 @@ public:
static TOOL_ACTION zoneUnfill;
static TOOL_ACTION zoneUnfillAll;
static TOOL_ACTION zoneMerge;
static TOOL_ACTION zoneDeleteSegzone;
/// Duplicate zone onto another layer
static TOOL_ACTION zoneDuplicate;

2
pcbnew/tools/pcb_editor_control.cpp

@ -304,6 +304,8 @@ bool PCB_EDITOR_CONTROL::Init()
menu.AddItem( PCB_ACTIONS::findMove, inactiveStateCondition );
menu.AddSeparator( inactiveStateCondition );
menu.AddItem( PCB_ACTIONS::zoneDeleteSegzone,
SELECTION_CONDITIONS::OnlyType( PCB_SEGZONE_T ) );
toolMenu.AddSubMenu( zoneMenu );
toolMenu.AddSubMenu( lockMenu );

33
pcbnew/tools/zone_filler_tool.cpp

@ -58,6 +58,10 @@ TOOL_ACTION PCB_ACTIONS::zoneUnfillAll( "pcbnew.ZoneFiller.zoneUnfillAll",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ZONE_REMOVE_FILLED ),
_( "Unfill All" ), _( "Unfill all zones" ) );
TOOL_ACTION PCB_ACTIONS::zoneDeleteSegzone( "pcbnew.ZoneFiller.zoneDeleteSegzone",
AS_GLOBAL, 0,
_( "Delete Zone Filling" ), _( "Delete Zone Filling" ), delete_xpm );
ZONE_FILLER_TOOL::ZONE_FILLER_TOOL() :
PCB_TOOL( "pcbnew.ZoneFiller" )
{
@ -148,6 +152,33 @@ int ZONE_FILLER_TOOL::ZoneUnfill( const TOOL_EVENT& aEvent )
}
int ZONE_FILLER_TOOL::SegzoneDeleteFill( const TOOL_EVENT& aEvent )
{
BOARD_COMMIT commit( this );
BOARD* board = (BOARD*) m_toolMgr->GetModel();
for( auto item : selection() )
{
assert( item->Type() == PCB_SEGZONE_T );
timestamp_t timestamp = item->GetTimeStamp(); // Save reference time stamp (aZone will be deleted)
SEGZONE* next;
for( SEGZONE* zone = board->m_SegZoneDeprecated; zone; zone = next )
{
next = zone->Next();
if( timestamp == zone->GetTimeStamp() )
commit.Remove( zone );
}
}
commit.Push( _( "Delete Zone Filling" ) );
return 0;
}
int ZONE_FILLER_TOOL::ZoneUnfillAll( const TOOL_EVENT& aEvent )
{
BOARD_COMMIT commit( this );
@ -172,5 +203,5 @@ void ZONE_FILLER_TOOL::setTransitions()
Go( &ZONE_FILLER_TOOL::ZoneFill, PCB_ACTIONS::zoneFill.MakeEvent() );
Go( &ZONE_FILLER_TOOL::ZoneFillAll, PCB_ACTIONS::zoneFillAll.MakeEvent() );
Go( &ZONE_FILLER_TOOL::ZoneUnfill, PCB_ACTIONS::zoneUnfill.MakeEvent() );
Go( &ZONE_FILLER_TOOL::ZoneUnfillAll, PCB_ACTIONS::zoneUnfillAll.MakeEvent() );
Go( &ZONE_FILLER_TOOL::SegzoneDeleteFill, PCB_ACTIONS::zoneDeleteSegzone.MakeEvent() );
}

3
pcbnew/tools/zone_filler_tool.h

@ -50,6 +50,9 @@ public:
int ZoneUnfill( const TOOL_EVENT& aEvent );
int ZoneUnfillAll( const TOOL_EVENT& aEvent );
// Segzone action
int SegzoneDeleteFill( const TOOL_EVENT& aEvent );
private:
///> Sets up handlers for various events.
void setTransitions() override;

Loading…
Cancel
Save