Commit 3bd6aa1d authored by charras's avatar charras

fixed: a bug that can delete an existing zone after creating a new zone (see changelog)

Switch to RC6
parent a575a8e7
...@@ -5,6 +5,13 @@ Started 2007-June-11 ...@@ -5,6 +5,13 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2009-mar-11 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
++pcbnew:
fixed: a bug that can delete an existing zone after creating a new zone,
if the new zone contains this existing zone
This is a DRC error, buf can be temporary possible when creating complex zones
2009-mar-10 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> 2009-mar-10 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================ ================================================================================
++pcbnew: ++pcbnew:
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#ifndef KICAD_BUILD_VERSION #ifndef KICAD_BUILD_VERSION
#define KICAD_BUILD_VERSION #define KICAD_BUILD_VERSION
#define BUILD_VERSION wxT("(20090216-RC5)") #define BUILD_VERSION wxT("(20090216-RC6)")
COMMON_GLOBL wxString g_BuildVersion COMMON_GLOBL wxString g_BuildVersion
#ifdef EDA_BASE #ifdef EDA_BASE
......
...@@ -60,7 +60,7 @@ ZONE_CONTAINER* BOARD::InsertArea( int netcode, int iarea, int layer, int x, int ...@@ -60,7 +60,7 @@ ZONE_CONTAINER* BOARD::InsertArea( int netcode, int iarea, int layer, int x, int
new_area->SetNet( netcode ); new_area->SetNet( netcode );
new_area->SetLayer( layer ); new_area->SetLayer( layer );
new_area->m_TimeStamp = GetTimeStamp(); new_area->m_TimeStamp = GetTimeStamp();
if( iarea < (int) ( m_ZoneDescriptorList.size() - 1) ) if( iarea < (int) ( m_ZoneDescriptorList.size() - 1 ) )
m_ZoneDescriptorList.insert( m_ZoneDescriptorList.begin() + iarea + 1, new_area ); m_ZoneDescriptorList.insert( m_ZoneDescriptorList.begin() + iarea + 1, new_area );
else else
m_ZoneDescriptorList.push_back( new_area ); m_ZoneDescriptorList.push_back( new_area );
...@@ -268,7 +268,7 @@ int BOARD::ClipAreaPolygon( ZONE_CONTAINER* CurrArea, ...@@ -268,7 +268,7 @@ int BOARD::ClipAreaPolygon( ZONE_CONTAINER* CurrArea,
//** TODO test for cutouts outside of area //** TODO test for cutouts outside of area
//** if( test == 1 ) //** if( test == 1 )
{ {
std::vector<CPolyLine*> * pa = new std::vector<CPolyLine*>; std::vector<CPolyLine*>* pa = new std::vector<CPolyLine*>;
curr_polygon->Undraw(); curr_polygon->Undraw();
int n_poly = CurrArea->m_Poly->NormalizeAreaOutlines( pa, bRetainArcs ); int n_poly = CurrArea->m_Poly->NormalizeAreaOutlines( pa, bRetainArcs );
if( n_poly > 1 ) // i.e if clipping has created some polygons, we must add these new copper areas if( n_poly > 1 ) // i.e if clipping has created some polygons, we must add these new copper areas
...@@ -327,7 +327,7 @@ int BOARD::AreaPolygonModified( ZONE_CONTAINER* modified_area, ...@@ -327,7 +327,7 @@ int BOARD::AreaPolygonModified( ZONE_CONTAINER* modified_area,
if( bCheckAllAreas ) if( bCheckAllAreas )
CombineAllAreasInNet( modified_area->GetNet(), bMessageBoxInt, true ); CombineAllAreasInNet( modified_area->GetNet(), bMessageBoxInt, true );
if ( layer >= FIRST_NO_COPPER_LAYER ) // Refill non copper zones on this layer if( layer >= FIRST_NO_COPPER_LAYER ) // Refill non copper zones on this layer
{ {
if( m_ZoneDescriptorList.size() > 0 ) if( m_ZoneDescriptorList.size() > 0 )
{ {
...@@ -336,17 +336,20 @@ int BOARD::AreaPolygonModified( ZONE_CONTAINER* modified_area, ...@@ -336,17 +336,20 @@ int BOARD::AreaPolygonModified( ZONE_CONTAINER* modified_area,
m_ZoneDescriptorList[ia]->BuildFilledPolysListData( this ); m_ZoneDescriptorList[ia]->BuildFilledPolysListData( this );
} }
} }
// Test for bad areas: all zones must have more than 2 corners: // Test for bad areas: all zones must have more than 2 corners:
// Note: should not happen, but just in case. // Note: should not happen, but just in case.
for( unsigned ia1 = 0; ia1 < m_ZoneDescriptorList.size() - 1; ) for( unsigned ia1 = 0; ia1 < m_ZoneDescriptorList.size() - 1; )
{ {
ZONE_CONTAINER* zone = m_ZoneDescriptorList[ia1]; ZONE_CONTAINER* zone = m_ZoneDescriptorList[ia1];
if( zone->GetNumCorners( ) >= 3 ) if( zone->GetNumCorners() >= 3 )
ia1++; ia1++;
// Remove zone because it is incorrect: // Remove zone because it is incorrect:
else else
RemoveArea( zone ); RemoveArea( zone );
} }
return test; return test;
} }
...@@ -362,8 +365,9 @@ int BOARD::AreaPolygonModified( ZONE_CONTAINER* modified_area, ...@@ -362,8 +365,9 @@ int BOARD::AreaPolygonModified( ZONE_CONTAINER* modified_area,
*/ */
int BOARD::CombineAllAreasInNet( int aNetCode, bool bMessageBox, bool bUseUtility ) int BOARD::CombineAllAreasInNet( int aNetCode, bool bMessageBox, bool bUseUtility )
{ {
if( m_ZoneDescriptorList.size() > 1 ) if( m_ZoneDescriptorList.size() <= 1 )
{ return 0;
// start by testing all area polygons to set utility2 flags // start by testing all area polygons to set utility2 flags
for( unsigned ia = 0; ia < m_ZoneDescriptorList.size(); ia++ ) for( unsigned ia = 0; ia < m_ZoneDescriptorList.size(); ia++ )
if( m_ZoneDescriptorList[ia]->GetNet() == aNetCode ) if( m_ZoneDescriptorList[ia]->GetNet() == aNetCode )
...@@ -382,6 +386,8 @@ int BOARD::CombineAllAreasInNet( int aNetCode, bool bMessageBox, bool bUseUtilit ...@@ -382,6 +386,8 @@ int BOARD::CombineAllAreasInNet( int aNetCode, bool bMessageBox, bool bUseUtilit
for( unsigned ia2 = m_ZoneDescriptorList.size() - 1; ia2 > ia1; ia2-- ) for( unsigned ia2 = m_ZoneDescriptorList.size() - 1; ia2 > ia1; ia2-- )
{ {
ZONE_CONTAINER* area2 = m_ZoneDescriptorList[ia2]; ZONE_CONTAINER* area2 = m_ZoneDescriptorList[ia2];
if( area2->GetNet() != aNetCode )
continue;
if( curr_area->GetLayer() == area2->GetLayer() if( curr_area->GetLayer() == area2->GetLayer()
&& curr_area->utility2 != -1 && area2->utility2 != -1 ) && curr_area->utility2 != -1 && area2->utility2 != -1 )
{ {
...@@ -423,7 +429,6 @@ int BOARD::CombineAllAreasInNet( int aNetCode, bool bMessageBox, bool bUseUtilit ...@@ -423,7 +429,6 @@ int BOARD::CombineAllAreasInNet( int aNetCode, bool bMessageBox, bool bUseUtilit
if( mod_ia1 ) if( mod_ia1 )
ia1--; // if modified, we need to check it again ia1--; // if modified, we need to check it again
} }
}
return 0; return 0;
} }
...@@ -707,8 +712,8 @@ int BOARD::CombineAreas( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_to_combi ...@@ -707,8 +712,8 @@ int BOARD::CombineAreas( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_to_combi
bool first = true; bool first = true;
while( booleng->PolygonHasMorePoints() ) while( booleng->PolygonHasMorePoints() )
{ {
int x = (int)booleng->GetPolygonXPoint(); int x = (int) booleng->GetPolygonXPoint();
int y = (int)booleng->GetPolygonYPoint(); int y = (int) booleng->GetPolygonYPoint();
if( first ) if( first )
{ {
first = false; first = false;
...@@ -767,8 +772,8 @@ int BOARD::CombineAreas( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_to_combi ...@@ -767,8 +772,8 @@ int BOARD::CombineAreas( ZONE_CONTAINER* area_ref, ZONE_CONTAINER* area_to_combi
} }
while( booleng->PolygonHasMorePoints() ) while( booleng->PolygonHasMorePoints() )
{ {
int x = (int)booleng->GetPolygonXPoint(); int x = (int) booleng->GetPolygonXPoint();
int y = (int)booleng->GetPolygonYPoint(); int y = (int) booleng->GetPolygonYPoint();
area_ref->m_Poly->AppendCorner( x, y ); area_ref->m_Poly->AppendCorner( x, y );
} }
...@@ -808,7 +813,7 @@ int BOARD::Test_Drc_Areas_Outlines_To_Areas_Outlines( ZONE_CONTAINER* aArea_To_E ...@@ -808,7 +813,7 @@ int BOARD::Test_Drc_Areas_Outlines_To_Areas_Outlines( ZONE_CONTAINER* aArea_To_E
for( int ia = 0; ia < GetAreaCount(); ia++ ) for( int ia = 0; ia < GetAreaCount(); ia++ )
{ {
ZONE_CONTAINER* Area_Ref = GetArea( ia ); ZONE_CONTAINER* Area_Ref = GetArea( ia );
if ( ! Area_Ref->IsOnCopperLayer() ) if( !Area_Ref->IsOnCopperLayer() )
continue; continue;
if( aArea_To_Examine && (aArea_To_Examine != Area_Ref) ) if( aArea_To_Examine && (aArea_To_Examine != Area_Ref) )
...@@ -959,7 +964,7 @@ int BOARD::Test_Drc_Areas_Outlines_To_Areas_Outlines( ZONE_CONTAINER* aArea_To_E ...@@ -959,7 +964,7 @@ int BOARD::Test_Drc_Areas_Outlines_To_Areas_Outlines( ZONE_CONTAINER* aArea_To_E
bool DRC::doEdgeZoneDrc( ZONE_CONTAINER* aArea, int aCornerIndex ) bool DRC::doEdgeZoneDrc( ZONE_CONTAINER* aArea, int aCornerIndex )
{ {
if ( ! aArea->IsOnCopperLayer() ) // Cannot have a Drc error if not on copper layer if( !aArea->IsOnCopperLayer() ) // Cannot have a Drc error if not on copper layer
return true; return true;
wxString str; wxString str;
...@@ -991,7 +996,8 @@ bool DRC::doEdgeZoneDrc( ZONE_CONTAINER* aArea, int aCornerIndex ) ...@@ -991,7 +996,8 @@ bool DRC::doEdgeZoneDrc( ZONE_CONTAINER* aArea, int aCornerIndex )
for( int ia2 = 0; ia2 < m_pcb->GetAreaCount(); ia2++ ) for( int ia2 = 0; ia2 < m_pcb->GetAreaCount(); ia2++ )
{ {
ZONE_CONTAINER* Area_To_Test = m_pcb->GetArea( ia2 ); ZONE_CONTAINER* Area_To_Test = m_pcb->GetArea( ia2 );
int zone_clearance = max(Area_To_Test->m_ZoneClearance, aArea->m_ZoneClearance); int zone_clearance = max( Area_To_Test->m_ZoneClearance,
aArea->m_ZoneClearance );
// test for same layer // test for same layer
if( Area_To_Test->GetLayer() != aArea->GetLayer() ) if( Area_To_Test->GetLayer() != aArea->GetLayer() )
......
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