Commit 64c1ea5c authored by Marco Mattila's avatar Marco Mattila

Add missing checks and undo support to pcbnew zone duplication.

parent 27d6310c
......@@ -196,6 +196,14 @@ protected:
*/
int propagate();
/**
* Function duplicateZone
* duplicates the given zone.
* @param aDC is the current Device Context.
* @param aZone is the zone to duplicate
*/
void duplicateZone( wxDC* aDC, ZONE_CONTAINER* aZone );
public:
PCB_LAYER_BOX_SELECTOR* m_SelLayerBox; // a combo box to display and select active layer
wxComboBox* m_SelTrackWidthBox; // a combo box to display and select current track width
......
......@@ -86,5 +86,6 @@ void ZONE_SETTINGS::ExportSetting( ZONE_CONTAINER& aTarget, bool aFullExport ) c
aTarget.SetPriority( m_ZonePriority );
aTarget.SetNet( m_NetcodeSelection );
aTarget.SetLayer( m_CurrentZone_Layer );
aTarget.m_Poly->SetLayer( m_CurrentZone_Layer );
}
}
......@@ -470,18 +470,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_ZONE_DUPLICATE:
{
ZONE_CONTAINER* zone = (ZONE_CONTAINER*) GetCurItem();
ZONE_CONTAINER* newZone = new ZONE_CONTAINER( m_Pcb );
newZone->Copy( zone );
ZONE_SETTINGS zoneSettings;
zoneSettings << *zone;
if( InvokeCopperZonesEditor( this, &zoneSettings ) )
{
zoneSettings.ExportSetting( *newZone );
m_Pcb->Add( newZone );
newZone->Draw( m_canvas, &dc, GR_OR );
}
else
delete newZone;
duplicateZone( &dc, zone );
}
break;
......
......@@ -107,6 +107,53 @@ void PCB_EDIT_FRAME::Add_Zone_Cutout( wxDC* DC, ZONE_CONTAINER* aZone )
}
void PCB_EDIT_FRAME::duplicateZone( wxDC* aDC, ZONE_CONTAINER* aZone )
{
ZONE_CONTAINER* newZone = new ZONE_CONTAINER( GetBoard() );
newZone->Copy( aZone );
newZone->UnFill();
ZONE_SETTINGS zoneSettings;
zoneSettings << *aZone;
if( InvokeCopperZonesEditor( this, &zoneSettings ) )
{
zoneSettings.ExportSetting( *newZone );
newZone->m_Poly->Hatch();
_AuxiliaryList.ClearListAndDeleteItems();
s_PickedList.ClearListAndDeleteItems();
SaveCopyOfZones( s_PickedList, GetBoard(), newZone->GetNet(), newZone->GetLayer() );
GetBoard()->Add( newZone );
ITEM_PICKER picker( newZone, UR_NEW );
s_PickedList.PushItem( picker );
GetScreen()->SetCurItem( NULL ); // This outline may be deleted when merging outlines
// Combine zones if possible
GetBoard()->AreaPolygonModified( &_AuxiliaryList, newZone, true, s_Verbose );
// Redraw zones
GetBoard()->RedrawAreasOutlines( m_canvas, aDC, GR_OR, newZone->GetLayer() );
GetBoard()->RedrawFilledAreas( m_canvas, aDC, GR_OR, newZone->GetLayer() );
if( GetBoard()->GetAreaIndex( newZone ) >= 0
&& GetBoard()->Test_Drc_Areas_Outlines_To_Areas_Outlines( newZone, true ) )
{
DisplayError( this, _( "Duplicate Zone: The outline of the duplicated zone fails DRC check!" ) );
}
UpdateCopyOfZonesList( s_PickedList, _AuxiliaryList, GetBoard() );
SaveCopyInUndoList( s_PickedList, UR_UNSPECIFIED );
s_PickedList.ClearItemsList();
OnModify();
}
else
delete newZone;
}
int PCB_EDIT_FRAME::Delete_LastCreatedCorner( wxDC* DC )
{
ZONE_CONTAINER* zone = GetBoard()->m_CurrentZoneContour;
......
......@@ -159,6 +159,7 @@ public:
void AppendArc( int xi, int yi, int xf, int yf, int xc, int yc, int num );
// access functions
void SetLayer( int aLayer ) { m_layer = aLayer; }
int GetLayer() { return m_layer; }
int GetNumCorners();
int GetNumSides();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment