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

Add missing checks and undo support to pcbnew zone duplication.

parent 27d6310c
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -196,6 +196,14 @@ protected:
     */
     */
    int propagate();
    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:
public:
    PCB_LAYER_BOX_SELECTOR* m_SelLayerBox;  // a combo box to display and select active layer
    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
    wxComboBox* m_SelTrackWidthBox;     // a combo box to display and select current track width
+1 −0
Original line number Original line Diff line number Diff line
@@ -86,5 +86,6 @@ void ZONE_SETTINGS::ExportSetting( ZONE_CONTAINER& aTarget, bool aFullExport ) c
        aTarget.SetPriority( m_ZonePriority );
        aTarget.SetPriority( m_ZonePriority );
        aTarget.SetNet( m_NetcodeSelection );
        aTarget.SetNet( m_NetcodeSelection );
        aTarget.SetLayer( m_CurrentZone_Layer );
        aTarget.SetLayer( m_CurrentZone_Layer );
        aTarget.m_Poly->SetLayer( m_CurrentZone_Layer );
    }
    }
}
}
+1 −12
Original line number Original line Diff line number Diff line
@@ -470,18 +470,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
    case ID_POPUP_PCB_ZONE_DUPLICATE:
    case ID_POPUP_PCB_ZONE_DUPLICATE:
    {
    {
        ZONE_CONTAINER* zone = (ZONE_CONTAINER*) GetCurItem();
        ZONE_CONTAINER* zone = (ZONE_CONTAINER*) GetCurItem();
        ZONE_CONTAINER* newZone = new ZONE_CONTAINER( m_Pcb );
        duplicateZone( &dc, zone );
        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;
    }
    }
    break;
    break;


+47 −0
Original line number Original line Diff line number Diff line
@@ -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 )
int PCB_EDIT_FRAME::Delete_LastCreatedCorner( wxDC* DC )
{
{
    ZONE_CONTAINER* zone = GetBoard()->m_CurrentZoneContour;
    ZONE_CONTAINER* zone = GetBoard()->m_CurrentZoneContour;
+1 −0
Original line number Original line Diff line number Diff line
@@ -159,6 +159,7 @@ public:
    void       AppendArc( int xi, int yi, int xf, int yf, int xc, int yc, int num );
    void       AppendArc( int xi, int yi, int xf, int yf, int xc, int yc, int num );


    // access functions
    // access functions
    void       SetLayer( int aLayer ) { m_layer = aLayer; }
    int        GetLayer() { return m_layer; }
    int        GetLayer() { return m_layer; }
    int        GetNumCorners();
    int        GetNumCorners();
    int        GetNumSides();
    int        GetNumSides();