From dad83c9004f4c1ecafe0a492e1fb44a13c7f2545 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 9 Feb 2013 21:03:20 +0100 Subject: [PATCH] Pcbnew: Try to find a better workaround for zone fiill bug (crash or bad fil areasl in very rare cases). pcbnew+Eeschema: Fix a very minor bug: filename not displayed in frame reference. --- common/worksheet.cpp | 5 +-- eeschema/eeredraw.cpp | 2 +- eeschema/schframe.cpp | 2 +- pcbnew/class_zone.cpp | 37 ++++++++++--------- pcbnew/tracepcb.cpp | 2 +- ...nvert_brd_items_to_polygons_with_Boost.cpp | 8 ---- ...ones_convert_to_polygons_aux_functions.cpp | 32 +++++++++++++--- 7 files changed, 50 insertions(+), 38 deletions(-) diff --git a/common/worksheet.cpp b/common/worksheet.cpp index e05409e0f5..e751077edb 100644 --- a/common/worksheet.cpp +++ b/common/worksheet.cpp @@ -1472,13 +1472,12 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, wxSize& aSz, wxPoint& aLT, wxPoi case WS_FILENAME: { - wxString fname, fext; - wxFileName::SplitPath( aFlNm, (wxString*) NULL, &fname, &fext ); + wxFileName fn( aFlNm ); if( WsItem->m_Legende ) msg = WsItem->m_Legende; - msg << fname << wxT( "." ) << fext; + msg << fn.GetFullName(); DrawGraphicText( m_canvas, aDC, pos, aClr1, msg, TEXT_ORIENT_HORIZ, size, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, diff --git a/eeschema/eeredraw.cpp b/eeschema/eeredraw.cpp index 7d20248404..30b928c99f 100644 --- a/eeschema/eeredraw.cpp +++ b/eeschema/eeredraw.cpp @@ -61,7 +61,7 @@ void SCH_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) GetScreen()->Draw( m_canvas, DC, GR_DEFAULT_DRAWMODE ); TraceWorkSheet( DC, GetScreen(), GetDefaultLineThickness(), IU_PER_MILS, - GetScreenDesc() ); + GetScreen()->GetFileName() ); #ifdef USE_WX_OVERLAY if( IsShown() ) diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index aa2d5bb95c..f9102268e6 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -852,7 +852,7 @@ void SCH_EDIT_FRAME::PrintPage( wxDC* aDC, int aPrintMask, bool aPrintMirrorMode { GetScreen()->Draw( m_canvas, aDC, GR_DEFAULT_DRAWMODE ); TraceWorkSheet( aDC, GetScreen(), GetDefaultLineThickness(), IU_PER_MILS, - GetScreenDesc() ); + GetScreen()->GetFileName() ); } diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index 5421d05894..a2d4322675 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -945,33 +945,34 @@ wxString ZONE_CONTAINER::GetSelectMenuText() const text << wxT( " " ); text << wxString::Format( wxT( "(%08lX)" ), m_TimeStamp ); - if ( !IsOnCopperLayer() ) + // Display net name for copper zones + if( !GetIsKeepout() ) { - text << wxT( " [" ) << _( "Not on copper layer" ) << wxT( "]" ); - } - else if( GetNet() >= 0 ) - { - if( board ) + if( GetNet() >= 0 ) { - net = board->FindNet( GetNet() ); - - if( net ) + if( board ) { - text << wxT( " [" ) << net->GetNetname() << wxT( "]" ); + net = board->FindNet( GetNet() ); + + if( net ) + { + text << wxT( " [" ) << net->GetNetname() << wxT( "]" ); + } + } + else + { + text << _( "** NO BOARD DEFINED **" ); } } else - { - text << _( "** NO BOARD DEFINED **" ); + { // A netcode < 0 is an error: + // Netname not found or area not initialised + text << wxT( " [" ) << m_Netname << wxT( "]" ); + text << wxT( " <" ) << _( "Not Found" ) << wxT( ">" ); } } - else // A netcode < 0 is an error flag (Netname not found or area not initialised) - { - text << wxT( " [" ) << m_Netname << wxT( "]" ); - text << wxT( " <" ) << _( "Not Found" ) << wxT( ">" ); - } - text << _( " on " ) << GetLayerName(); + text << _( " on layer " ) << GetLayerName(); return text; } diff --git a/pcbnew/tracepcb.cpp b/pcbnew/tracepcb.cpp index 35385c1506..d61089dcef 100644 --- a/pcbnew/tracepcb.cpp +++ b/pcbnew/tracepcb.cpp @@ -109,7 +109,7 @@ void PCB_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) m_canvas->DrawBackGround( DC ); TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness, - IU_PER_MILS, wxEmptyString ); + IU_PER_MILS, GetBoard()->GetFileName() ); GetBoard()->Draw( m_canvas, DC, GR_OR | GR_ALLOW_HIGHCONTRAST ); diff --git a/pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp b/pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp index bc0350f9ea..8e229fc905 100644 --- a/pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp +++ b/pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp @@ -453,14 +453,6 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) { KI_POLYGON_SET polyset_holes; AddPolygonCornersToKiPolygonList( cornerBufferPolysToSubstract, polyset_holes ); - // In very rare cases, the next calculation crashes when Pcbnew is in nanometers. - // the crash is inside boost::polygon (tested with version 1.49 and 1.53, - // so this crash is nearly impossible to fix - // and a workaround is here to combine the polygons to substract, to modify - // the geometry of the polygons to substract, because - // the 2 known cases are related to 2 rectangular overlapping rect to substract - // with a given geometry - KI_POLYGON_SET dummy; polyset_holes += dummy; // Remove unconnected stubs polyset_zone_solid_areas -= polyset_holes; diff --git a/pcbnew/zones_convert_to_polygons_aux_functions.cpp b/pcbnew/zones_convert_to_polygons_aux_functions.cpp index ace4212a1b..1bf48a1252 100644 --- a/pcbnew/zones_convert_to_polygons_aux_functions.cpp +++ b/pcbnew/zones_convert_to_polygons_aux_functions.cpp @@ -76,10 +76,6 @@ void BuildUnconnectedThermalStubsPolygonList( std::vector& aCornerBuffe { for( D_PAD* pad = module->m_Pads; pad != NULL; pad = pad->Next() ) { - // Calculate thermal bridge half width - int thermalBridgeWidth = aZone->GetThermalReliefCopperBridge( pad ) / 2; - int thermalReliefGap = aZone->GetThermalReliefGap( pad ); - // Rejects non-standard pads with tht-only thermal reliefs if( aZone->GetPadConnection( pad ) == THT_THERMAL && pad->GetAttribute() != PAD_STANDARD ) @@ -96,6 +92,19 @@ void BuildUnconnectedThermalStubsPolygonList( std::vector& aCornerBuffe if( pad->GetNet() != aZone->GetNet() ) continue; + // Calculate thermal bridge half width + int thermalBridgeWidth = aZone->GetThermalReliefCopperBridge( pad ) + - aZone->m_ZoneMinThickness; + if( thermalBridgeWidth <= 0 ) + continue; + + // we need the thermal bridge half width + // with a small extra size to be sure we create a stub + // slightly larger than the actual stub + thermalBridgeWidth = ( thermalBridgeWidth + 4 ) / 2; + + int thermalReliefGap = aZone->GetThermalReliefGap( pad ); + item_boundingbox = pad->GetBoundingBox(); item_boundingbox.Inflate( thermalReliefGap ); if( !( item_boundingbox.Intersects( zone_boundingbox ) ) ) @@ -103,16 +112,26 @@ void BuildUnconnectedThermalStubsPolygonList( std::vector& aCornerBuffe // Thermal bridges are like a segment from a starting point inside the pad // to an ending point outside the pad - wxPoint startpoint, endpoint; + + // calculate the ending point of the thermal pad, outside the pad + wxPoint endpoint; endpoint.x = ( pad->GetSize().x / 2 ) + thermalReliefGap; endpoint.y = ( pad->GetSize().y / 2 ) + thermalReliefGap; - int copperThickness = aZone->GetThermalReliefCopperBridge( pad ) - aZone->m_ZoneMinThickness; + // Calculate the starting point of the thermal stub + // inside the pad + wxPoint startpoint; + int copperThickness = aZone->GetThermalReliefCopperBridge( pad ) + - aZone->m_ZoneMinThickness; if( copperThickness < 0 ) copperThickness = 0; + // Leave a small extra size to the copper area inside to pad + copperThickness += (int)(IU_PER_MM * 0.04); + startpoint.x = std::min( pad->GetSize().x, copperThickness ); startpoint.y = std::min( pad->GetSize().y, copperThickness ); + startpoint.x /= 2; startpoint.y /= 2; @@ -143,6 +162,7 @@ void BuildUnconnectedThermalStubsPolygonList( std::vector& aCornerBuffe // translate point ptTest[i] += pad->ReturnShapePos(); + if( aZone->HitTestFilledArea( ptTest[i] ) ) continue;