From 771ac33c807ee407524c0ef878a7ca532b790b85 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 29 May 2014 13:48:14 +0200 Subject: [PATCH] Pcbnew: fix a minor bug: in zones with no net, only the zone clerance was used to created clearence, regardless the pad or footprint local clerance. Very minor other fixes. --- common/class_marker_base.cpp | 4 +- ...board_items_to_polygon_shape_transform.cpp | 2 +- pcbnew/router/pns_router.cpp | 42 +++++++++---------- pcbnew/router/pns_via.h | 4 +- ...nvert_brd_items_to_polygons_with_Boost.cpp | 14 ++++--- 5 files changed, 35 insertions(+), 31 deletions(-) diff --git a/common/class_marker_base.cpp b/common/class_marker_base.cpp index 6e54012fd4..358975ff8e 100644 --- a/common/class_marker_base.cpp +++ b/common/class_marker_base.cpp @@ -19,8 +19,8 @@ // Default marquer shape: -const int M_SHAPE_SCALE = 6; // default scaling factor for MarkerShapeCorners coordinates -const int CORNERS_COUNT = 8; +const int M_SHAPE_SCALE = 6; // default scaling factor for MarkerShapeCorners coordinates +const unsigned CORNERS_COUNT = 8; /* corners of the default shape * actual coordinates are these values * .m_ScalingFactor */ diff --git a/pcbnew/board_items_to_polygon_shape_transform.cpp b/pcbnew/board_items_to_polygon_shape_transform.cpp index d4122e7b93..0651f00efe 100644 --- a/pcbnew/board_items_to_polygon_shape_transform.cpp +++ b/pcbnew/board_items_to_polygon_shape_transform.cpp @@ -54,7 +54,7 @@ static void addTextSegmToPoly( int x0, int y0, int xf, int yf ) void BOARD::ConvertBrdLayerToPolygonalContours( LAYER_NUM aLayer, CPOLYGONS_LIST& aOutlines ) { // Number of segments to convert a circle to a polygon - const int segcountforcircle = 16; + const int segcountforcircle = 18; double correctionFactor = 1.0 / cos( M_PI / (segcountforcircle * 2) ); // convert tracks and vias: diff --git a/pcbnew/router/pns_router.cpp b/pcbnew/router/pns_router.cpp index 596b5a5cd7..a41c9b9b49 100644 --- a/pcbnew/router/pns_router.cpp +++ b/pcbnew/router/pns_router.cpp @@ -131,13 +131,13 @@ PNS_ITEM* PNS_ROUTER::syncPad( D_PAD* aPad ) int i; for( i = FIRST_COPPER_LAYER; i <= LAST_COPPER_LAYER; i++ ) - { + { if( lmsk & ( 1 << i ) ) { layers = PNS_LAYERSET( i ); break; } - } + } break; } @@ -189,7 +189,7 @@ PNS_ITEM* PNS_ROUTER::syncPad( D_PAD* aPad ) if( sz.x > sz.y ) delta = VECTOR2I( ( sz.x - sz.y ) / 2, 0 ); - else + else delta = VECTOR2I( 0, ( sz.y - sz.x ) / 2 ); SHAPE_SEGMENT* shape = new SHAPE_SEGMENT( c - delta, c + delta, @@ -284,11 +284,11 @@ void PNS_ROUTER::SyncWorld() ClearWorld(); int worstClearance = m_board->GetDesignSettings().GetBiggestClearanceValue(); - + m_clearanceFunc = new PCBNEW_CLEARANCE_FUNC( m_board ); m_world = new PNS_NODE(); m_world->SetClearanceFunctor( m_clearanceFunc ); - m_world->SetMaxClearance( 4 * worstClearance ); + m_world->SetMaxClearance( 4 * worstClearance ); for( MODULE* module = m_board->m_Modules; module; module = module->Next() ) { @@ -462,7 +462,7 @@ bool PNS_ROUTER::StartDragging( const VECTOR2I& aP, PNS_ITEM* aStartItem ) { if( !aStartItem || aStartItem->OfKind( PNS_ITEM::SOLID ) ) return false; - + m_dragger = new PNS_DRAGGER ( this ); m_dragger->SetWorld( m_world ); @@ -474,7 +474,7 @@ bool PNS_ROUTER::StartDragging( const VECTOR2I& aP, PNS_ITEM* aStartItem ) m_state = IDLE; return false; } - + return true; } @@ -489,7 +489,7 @@ bool PNS_ROUTER::StartRouting( const VECTOR2I& aP, PNS_ITEM* aStartItem ) m_placer->Start( aP, aStartItem ); m_currentEnd = aP; m_currentEndItem = NULL; - + return true; } @@ -603,7 +603,7 @@ void PNS_ROUTER::markViolations( PNS_NODE* aNode, PNS_ITEMSET& aCurrent, PNS_NODE::OBSTACLES obstacles; aNode->QueryColliding( item, obstacles, PNS_ITEM::ANY ); - + if( item->OfKind( PNS_ITEM::LINE ) ) { PNS_LINE *l = static_cast( item ); @@ -617,7 +617,7 @@ void PNS_ROUTER::markViolations( PNS_NODE* aNode, PNS_ITEMSET& aCurrent, BOOST_FOREACH( PNS_OBSTACLE& obs, obstacles ) { - int clearance = aNode->GetClearance( item, obs.m_item ); + int clearance = aNode->GetClearance( item, obs.m_item ); std::auto_ptr tmp( obs.m_item->Clone() ); tmp->Mark( MK_VIOLATION ); DisplayItem( tmp.get(), -1, clearance ); @@ -631,13 +631,13 @@ void PNS_ROUTER::updateView( PNS_NODE* aNode, PNS_ITEMSET& aCurrent ) { PNS_NODE::ITEM_VECTOR removed, added; PNS_NODE::OBSTACLES obstacles; - + if( !aNode ) return; - + if( Settings().Mode() == RM_MarkObstacles ) markViolations(aNode, aCurrent, removed); - + aNode->GetUpdatedItems( removed, added ); BOOST_FOREACH( PNS_ITEM* item, added ) @@ -679,7 +679,7 @@ void PNS_ROUTER::movePlacing( const VECTOR2I& aP, PNS_ITEM* aEndItem ) m_placer->Move( aP, aEndItem ); PNS_LINE current = m_placer->Trace(); - + DisplayItem( ¤t ); if( current.EndsWithVia() ) @@ -790,18 +790,18 @@ bool PNS_ROUTER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem ) rv = m_placer->FixRoute( aP, aEndItem ); m_placingVia = false; break; - + case DRAG_SEGMENT: rv = m_dragger->FixRoute(); break; - + default: - break; - } + break; + } if( rv ) StopRouting(); - + return rv; } @@ -909,10 +909,10 @@ void PNS_ROUTER::DumpLog() case DRAG_SEGMENT: logger = m_dragger->Logger(); break; - + default: break; - } + } if( logger ) logger->Save ( "/tmp/shove.log" ); diff --git a/pcbnew/router/pns_via.h b/pcbnew/router/pns_via.h index 914ea758cb..dcf7abdf1f 100644 --- a/pcbnew/router/pns_via.h +++ b/pcbnew/router/pns_via.h @@ -108,13 +108,13 @@ public: PNS_VIA* Clone() const; const SHAPE_LINE_CHAIN Hull( int aClearance = 0, int aWalkaroundThickness = 0 ) const; - + virtual VECTOR2I Anchor( int n ) const { return m_pos; } - virtual int AnchorCount() const + virtual int AnchorCount() const { return 1; } 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 b41d859b65..8b46ad8e8b 100644 --- a/pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp +++ b/pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp @@ -199,9 +199,11 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) */ MODULE dummymodule( aPcb ); // Creates a dummy parent D_PAD dummypad( &dummymodule ); - D_PAD* nextpad; + for( MODULE* module = aPcb->m_Modules; module; module = module->Next() ) { + D_PAD* nextpad; + for( D_PAD* pad = module->Pads(); pad != NULL; pad = nextpad ) { nextpad = pad->Next(); // pad pointer can be modified by next code, so @@ -228,7 +230,8 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) pad = &dummypad; } - if( pad->GetNetCode() != GetNetCode() ) + // Note: netcode <=0 means not connected item + if( ( pad->GetNetCode() != GetNetCode() ) || ( pad->GetNetCode() <= 0 ) ) { item_clearance = pad->GetClearance() + margin; item_boundingbox = pad->GetBoundingBox(); @@ -246,14 +249,15 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) continue; } - int gap = zone_clearance; - if( ( GetPadConnection( pad ) == PAD_NOT_IN_ZONE ) - || ( GetNetCode() == 0 ) || ( pad->GetShape() == PAD_TRAPEZOID ) ) + || ( pad->GetShape() == PAD_TRAPEZOID ) ) // PAD_TRAPEZOID shapes are not in zones because they are used in microwave apps // and i think it is good that shapes are not changed by thermal pads or others { + int gap = zone_clearance; + int thermalGap = GetThermalReliefGap( pad ); + gap = std::max( gap, thermalGap ); item_boundingbox = pad->GetBoundingBox(); if( item_boundingbox.Intersects( zone_boundingbox ) )