From 9deee66b179077d3d5d92416e067d3ba629d7e48 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 16 Jul 2011 18:04:49 +0200 Subject: [PATCH] Pcbnew: Fix bug 811437 . This bug (due to duplicate time stamps), cannot happen with usual boards, only when 2 identical board (from the same .brd file) are append. --- include/wxPcbStruct.h | 9 +++++---- pcbnew/class_zone.cpp | 16 ++++++++++++++++ pcbnew/class_zone.h | 7 +++++++ pcbnew/edit.cpp | 6 +++--- pcbnew/zones_by_polygon.cpp | 8 ++++++-- pcbnew/zones_by_polygon_fill_functions.cpp | 22 +++++----------------- 6 files changed, 42 insertions(+), 26 deletions(-) diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index 622db34952..d089a3f925 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -902,15 +902,16 @@ public: // zone handling /** - * Function Delete_Zone_Fill (obsolete) + * Function Delete_OldZone_Fill (obsolete) + * Used for compatibility with old boards * Remove the zone filling which include the segment aZone, or the zone - * which have the given time stamp. A zone is a group of segments which - * have the same TimeStamp + * which have the given time stamp. + * For old boards, a zone is a group of SEGZONE segments which have the same TimeStamp * @param aZone = zone segment within the zone to delete. Can be NULL * @param aTimestamp = Timestamp for the zone to delete, used if aZone == * NULL */ - void Delete_Zone_Fill( SEGZONE* aZone, long aTimestamp = 0 ); + void Delete_OldZone_Fill( SEGZONE* aZone, long aTimestamp = 0 ); /** diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index a4b7e18390..617e1523fb 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -47,6 +47,22 @@ ZONE_CONTAINER::~ZONE_CONTAINER() m_Poly = NULL; } +/** + * Function UnFill + * Removes the zone filling + * @return true if a previous filling is removed, false if no change + * (when no filling found) + */ +bool ZONE_CONTAINER::UnFill() +{ + bool change = ( m_FilledPolysList.size() > 0 ) || ( m_FillSegmList.size() > 0 ); + + m_FilledPolysList.clear(); + m_FillSegmList.clear(); + m_IsFilled = false; + + return change; +} /** * Function GetPosition (virtual) diff --git a/pcbnew/class_zone.h b/pcbnew/class_zone.h index d5d9e10699..c23cac5830 100644 --- a/pcbnew/class_zone.h +++ b/pcbnew/class_zone.h @@ -289,6 +289,13 @@ public: */ int Fill_Zone_Areas_With_Segments(); + /** + * Function UnFill + * Removes the zone filling + * @return true if a previous filling is removed, false if no change + * (when no filling found) + */ + bool UnFill(); /* Geometric transformations: */ diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 600f898d2c..fb612b2a35 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -381,7 +381,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) { SEGZONE* zsegm = (SEGZONE*) GetCurItem(); int netcode = zsegm->GetNet(); - Delete_Zone_Fill( zsegm ); + Delete_OldZone_Fill( zsegm ); SetCurItem( NULL ); test_1_net_connexion( NULL, netcode ); OnModify(); @@ -498,7 +498,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) if( ( GetCurItem() )->Type() == TYPE_ZONE_CONTAINER ) { ZONE_CONTAINER* zone_container = (ZONE_CONTAINER*) GetCurItem(); - Delete_Zone_Fill( NULL, zone_container->m_TimeStamp ); + zone_container->UnFill(); test_1_net_connexion( NULL, zone_container->GetNet() ); OnModify(); GetBoard()->DisplayInfo( this ); @@ -1058,7 +1058,7 @@ void PCB_EDIT_FRAME::RemoveStruct( BOARD_ITEM* Item, wxDC* DC ) break; case TYPE_ZONE: - Delete_Zone_Fill( (SEGZONE*) Item ); + Delete_OldZone_Fill( (SEGZONE*) Item ); break; case TYPE_ZONE_EDGE_CORNER: diff --git a/pcbnew/zones_by_polygon.cpp b/pcbnew/zones_by_polygon.cpp index eed524a3fc..bc976944e1 100644 --- a/pcbnew/zones_by_polygon.cpp +++ b/pcbnew/zones_by_polygon.cpp @@ -335,7 +335,7 @@ void PCB_EDIT_FRAME::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_containe DrawPanel->RefreshDrawingRect( zone_container->GetBoundingBox() ); if( DC ) { // Remove the full zone because this is no more an area - Delete_Zone_Fill( NULL, zone_container->m_TimeStamp ); + zone_container->UnFill(); zone_container->DrawFilledArea( DrawPanel, DC, GR_XOR ); } GetBoard()->Delete( zone_container ); @@ -851,7 +851,11 @@ void PCB_EDIT_FRAME::Delete_Zone_Contour( wxDC* DC, ZONE_CONTAINER* zone_contain EDA_RECT dirty = zone_container->GetBoundingBox(); - Delete_Zone_Fill( NULL, zone_container->m_TimeStamp ); // Remove fill segments + // For compatibility with old boards: remove old SEGZONE fill segments + Delete_OldZone_Fill( NULL, zone_container->m_TimeStamp ); + + // Remove current filling: + zone_container->UnFill(); if( ncont == 0 ) // This is the main outline: remove all { diff --git a/pcbnew/zones_by_polygon_fill_functions.cpp b/pcbnew/zones_by_polygon_fill_functions.cpp index 0fd3731425..b3f02ffbdc 100644 --- a/pcbnew/zones_by_polygon_fill_functions.cpp +++ b/pcbnew/zones_by_polygon_fill_functions.cpp @@ -36,13 +36,14 @@ /** - * Function Delete_Zone_Fill - * Remove the zone fillig which include the segment aZone, or the zone which have the given time stamp. + * Function Delete_OldZone_Fill (obsolete) + * Used for compatibility with old boards + * Remove the zone filling which include the segment aZone, or the zone which have the given time stamp. * A zone is a group of segments which have the same TimeStamp * @param aZone = zone segment within the zone to delete. Can be NULL * @param aTimestamp = Timestamp for the zone to delete, used if aZone == NULL */ -void PCB_EDIT_FRAME::Delete_Zone_Fill( SEGZONE* aZone, long aTimestamp ) +void PCB_EDIT_FRAME::Delete_OldZone_Fill( SEGZONE* aZone, long aTimestamp ) { bool modify = false; unsigned long TimeStamp; @@ -64,19 +65,6 @@ void PCB_EDIT_FRAME::Delete_Zone_Fill( SEGZONE* aZone, long aTimestamp ) } } - // Now delete the outlines of the corresponding copper areas (deprecated) - for( int ii = 0; ii < GetBoard()->GetAreaCount(); ii++ ) - { - ZONE_CONTAINER* zone = GetBoard()->GetArea( ii ); - if( zone->m_TimeStamp == TimeStamp ) - { - modify = TRUE; - zone->m_FilledPolysList.clear(); - zone->m_FillSegmList.clear(); - zone->m_IsFilled = false; - } - } - if( modify ) { OnModify(); @@ -120,7 +108,7 @@ int PCB_EDIT_FRAME::Fill_Zone( ZONE_CONTAINER* zone_container, bool verbose ) wxBusyCursor dummy; // Shows an hourglass cursor (removed by its destructor) zone_container->m_FilledPolysList.clear(); - Delete_Zone_Fill( NULL, zone_container->m_TimeStamp ); + zone_container->UnFill(); zone_container->BuildFilledPolysListData( GetBoard() ); OnModify();